New issue 703: pytest discovers baseclasses that are imported and attempts to
run them
https://bitbucket.org/pytest-dev/pytest/issue/703/pytest-discovers-baseclasses-that-are
Anthony Sottile:
```
# testing.py
import unittest
class BaseTest(unittest.TestCase):
fill_me_out = None
def test(self):
assert self.fill_me_out is not None
```
```
# test.py
from testing import BaseTest
class MyTest(BaseTest):
fill_me_out = 10
```
Expected:
```
$ py.test test.py -vv
============================= test session starts ==============================
platform linux2 -- Python 2.6.7 -- py-1.4.26 -- pytest-2.6.4 --
/tmp/venv/bin/python
collected 1 items
test.py <- testing.py::MyTest::test PASSED
=========================== 1 passed in 0.01 seconds ===========================
```
Actual:
```
$ py.test test.py -vv
============================= test session starts ==============================
platform linux2 -- Python 2.6.7 -- py-1.4.26 -- pytest-2.6.4 --
/tmp/venv/bin/python
collected 2 items
test.py <- testing.py::MyTest::test PASSED
test.py <- testing.py::BaseTest::test FAILED
=================================== FAILURES ===================================
________________________________ BaseTest.test _________________________________
self = <testing.BaseTest testMethod=test>
def test(self):
> assert self.fill_me_out is not None
E AssertionError: assert None is not None
E + where None = <testing.BaseTest testMethod=test>.fill_me_out
testing.py:9: AssertionError
====================== 1 failed, 1 passed in 0.01 seconds ======================
```
To clarify the behaviour I want: classes / functions that are only in a module
because they are an import side-effect should not be discovered.
Obligatory version:
```
$ py.test --version
This is pytest version 2.6.4, imported from
/tmp/venv/lib/python2.6/site-packages/pytest.pyc
```
_______________________________________________
pytest-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-commit