fix tests to properly fail on failed collectiosn (which was hiding an error)
and also implement __test__=False for test functions properly. --HG-- branch : nose_test_attr
This commit is contained in:
parent
e42cbc714f
commit
15af7e1662
|
@ -229,10 +229,11 @@ def pytest_pycollect_makeitem(__multicall__, collector, name, obj):
|
|||
"cannot collect %r because it is not a function."
|
||||
% name, )
|
||||
return
|
||||
if is_generator(obj):
|
||||
return Generator(name, parent=collector)
|
||||
else:
|
||||
return list(collector._genfunctions(name, obj))
|
||||
if getattr(obj, "__test__", True):
|
||||
if is_generator(obj):
|
||||
return Generator(name, parent=collector)
|
||||
else:
|
||||
return list(collector._genfunctions(name, obj))
|
||||
|
||||
def is_generator(func):
|
||||
try:
|
||||
|
|
|
@ -225,6 +225,7 @@ class TestNoselikeTestAttribute:
|
|||
pass
|
||||
""")
|
||||
reprec = testdir.inline_run()
|
||||
assert not reprec.getfailedcollections()
|
||||
calls = reprec.getreports("pytest_runtest_logreport")
|
||||
assert not calls
|
||||
|
||||
|
@ -233,7 +234,7 @@ class TestNoselikeTestAttribute:
|
|||
__test__ = True
|
||||
def test_func():
|
||||
pass
|
||||
test_hello.__test__ = False
|
||||
test_func.__test__ = False
|
||||
|
||||
class TestSome:
|
||||
__test__ = False
|
||||
|
@ -241,6 +242,7 @@ class TestNoselikeTestAttribute:
|
|||
pass
|
||||
""")
|
||||
reprec = testdir.inline_run()
|
||||
assert not reprec.getfailedcollections()
|
||||
calls = reprec.getreports("pytest_runtest_logreport")
|
||||
assert not calls
|
||||
|
||||
|
@ -256,6 +258,7 @@ class TestNoselikeTestAttribute:
|
|||
pass
|
||||
""")
|
||||
reprec = testdir.inline_run()
|
||||
assert not reprec.getfailedcollections()
|
||||
call = reprec.getcalls("pytest_collection_modifyitems")[0]
|
||||
assert len(call.items) == 1
|
||||
assert call.items[0].cls.__name__ == "TC"
|
||||
|
|
Loading…
Reference in New Issue