Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ merlinux GmbH, Germany, office at merlinux eu

Contributors include::

Abdeali JK
Abhijeet Kasurde
Anatoly Bubenkoff
Andreas Zeidler
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

**New Features**

* Support nose-style ``__test__`` attribute on methods of classes,
including unittest-style Classes. If set to False, the test will not be
collected.

* New ``doctest_namespace`` fixture for injecting names into the
namespace in which your doctests run.
Thanks `@milliams`_ for the complete PR (`#1428`_).
Expand Down
2 changes: 2 additions & 0 deletions _pytest/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def collect(self):
foundsomething = False
for name in loader.getTestCaseNames(self.obj):
x = getattr(self.obj, name)
if not getattr(x, '__test__', True):
continue
funcobj = getattr(x, 'im_func', x)
transfer_markers(funcobj, cls, module)
yield TestCaseFunction(name, parent=self)
Expand Down
14 changes: 14 additions & 0 deletions testing/test_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,3 +735,17 @@ def test_skip(self):
*SKIP*[1]*skipping due to reasons*
*1 skipped*
""")

def test_class_method_containing_test_issue1558(testdir):
testdir.makepyfile(test_foo="""
import unittest

class MyTestCase(unittest.TestCase):
def test_should_run(self):
pass
def test_should_not_run(self):
pass
test_should_not_run.__test__ = False
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1)