Skip to content

Instantly share code, notes, and snippets.

@shangxiao
Created July 3, 2019 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shangxiao/35686b9aec169a8e20c042cc53ddba68 to your computer and use it in GitHub Desktop.
Save shangxiao/35686b9aec169a8e20c042cc53ddba68 to your computer and use it in GitHub Desktop.
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