Skip to content

Instantly share code, notes, and snippets.

@shangxiao
Created Jul 3, 2019
Embed
What would you like to do?
Pytest not raising import exceptions for regular classes?
shangxiao ~/projects/test-pytest $ pytest
========================================================= test session starts =========================================================
platform darwin -- Python 3.6.2, pytest-5.0.0, py-1.8.0, pluggy-0.12.0
rootdir: /Users/shangxiao/projects/test-pytest
collected 1 item
test_foo.py F [100%]
============================================================== FAILURES ===============================================================
________________________________________________________ FooTestCase.test_foo _________________________________________________________
self = <test_foo.FooTestCase testMethod=test_foo>
def test_foo(self):
> foo = Foo()
E NameError: name 'Foo' is not defined
test_foo.py:6: NameError
====================================================== 1 failed in 0.04 seconds =======================================================
shangxiao ~/projects/test-pytest $
class BarTestCase:
def test_bar(self):
bar = Bar()
assert True
from unittest import TestCase
class FooTestCase(TestCase):
def test_foo(self):
foo = Foo()
assert True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment