parent
f02b84d528
commit
4656bc4c97
|
@ -13,6 +13,8 @@ Changes between 1.X and 1.1.1
|
||||||
|
|
||||||
- allow pytest_generate_tests to be defined in classes as well
|
- allow pytest_generate_tests to be defined in classes as well
|
||||||
|
|
||||||
|
- deprecate usage of 'disabled' attribute in favour of pytestmark
|
||||||
|
|
||||||
- collection/item node specific runtest/collect hooks are only called exactly
|
- collection/item node specific runtest/collect hooks are only called exactly
|
||||||
on matching conftest.py files, i.e. ones which are exactly below
|
on matching conftest.py files, i.e. ones which are exactly below
|
||||||
the filesystem path of an item
|
the filesystem path of an item
|
||||||
|
|
|
@ -167,6 +167,8 @@ class Module(py.test.collect.File, PyCollectorMixin):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
if getattr(self.obj, 'disabled', 0):
|
if getattr(self.obj, 'disabled', 0):
|
||||||
|
py.log._apiwarn(">1.1.1", "%r uses 'disabled' which is deprecated, "
|
||||||
|
"use pytestmark=..., see pytest_skipping plugin" % (self.obj,))
|
||||||
py.test.skip("%r is disabled" %(self.obj,))
|
py.test.skip("%r is disabled" %(self.obj,))
|
||||||
if hasattr(self.obj, 'setup_module'):
|
if hasattr(self.obj, 'setup_module'):
|
||||||
#XXX: nose compat hack, move to nose plugin
|
#XXX: nose compat hack, move to nose plugin
|
||||||
|
@ -197,6 +199,8 @@ class Class(PyCollectorMixin, py.test.collect.Collector):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
if getattr(self.obj, 'disabled', 0):
|
if getattr(self.obj, 'disabled', 0):
|
||||||
|
py.log._apiwarn(">1.1.1", "%r uses 'disabled' which is deprecated, "
|
||||||
|
"use pytestmark=..., see pytest_skipping plugin" % (self.obj,))
|
||||||
py.test.skip("%r is disabled" %(self.obj,))
|
py.test.skip("%r is disabled" %(self.obj,))
|
||||||
setup_class = getattr(self.obj, 'setup_class', None)
|
setup_class = getattr(self.obj, 'setup_class', None)
|
||||||
if setup_class is not None:
|
if setup_class is not None:
|
||||||
|
|
|
@ -72,6 +72,7 @@ def deprecated_call(func, *args, **kwargs):
|
||||||
warningmodule.warn = warn
|
warningmodule.warn = warn
|
||||||
if not l:
|
if not l:
|
||||||
#print warningmodule
|
#print warningmodule
|
||||||
|
__tracebackhide__ = True
|
||||||
raise AssertionError("%r did not produce DeprecationWarning" %(func,))
|
raise AssertionError("%r did not produce DeprecationWarning" %(func,))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
from py.impl.test.outcome import Skipped
|
||||||
|
|
||||||
class TestCollectDeprecated:
|
class TestCollectDeprecated:
|
||||||
|
|
||||||
|
@ -167,3 +168,45 @@ class TestCollectDeprecated:
|
||||||
config = testdir.parseconfig(testme)
|
config = testdir.parseconfig(testme)
|
||||||
col = config.getfsnode(testme)
|
col = config.getfsnode(testme)
|
||||||
assert col.collect() == []
|
assert col.collect() == []
|
||||||
|
|
||||||
|
|
||||||
|
class TestDisabled:
|
||||||
|
def test_disabled_module(self, recwarn, testdir):
|
||||||
|
modcol = testdir.getmodulecol("""
|
||||||
|
disabled = True
|
||||||
|
def setup_module(mod):
|
||||||
|
raise ValueError
|
||||||
|
def test_method():
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
l = modcol.collect()
|
||||||
|
assert len(l) == 1
|
||||||
|
recwarn.clear()
|
||||||
|
py.test.raises(Skipped, "modcol.setup()")
|
||||||
|
recwarn.pop(DeprecationWarning)
|
||||||
|
|
||||||
|
def test_disabled_class(self, recwarn, testdir):
|
||||||
|
modcol = testdir.getmodulecol("""
|
||||||
|
class TestClass:
|
||||||
|
disabled = True
|
||||||
|
def test_method(self):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
l = modcol.collect()
|
||||||
|
assert len(l) == 1
|
||||||
|
modcol = l[0]
|
||||||
|
assert isinstance(modcol, py.test.collect.Class)
|
||||||
|
l = modcol.collect()
|
||||||
|
assert len(l) == 1
|
||||||
|
recwarn.clear()
|
||||||
|
py.test.raises(Skipped, "modcol.setup()")
|
||||||
|
recwarn.pop(DeprecationWarning)
|
||||||
|
|
||||||
|
def test_disabled_class_functional(self, testdir):
|
||||||
|
reprec = testdir.inline_runsource("""
|
||||||
|
class TestSimpleClassSetup:
|
||||||
|
disabled = True
|
||||||
|
def test_classlevel(self): pass
|
||||||
|
def test_classlevel2(self): pass
|
||||||
|
""")
|
||||||
|
reprec.assertoutcome(skipped=2)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import py
|
import py
|
||||||
|
|
||||||
from py.impl.test.outcome import Skipped
|
|
||||||
|
|
||||||
class TestModule:
|
class TestModule:
|
||||||
def test_module_file_not_found(self, testdir):
|
def test_module_file_not_found(self, testdir):
|
||||||
tmpdir = testdir.tmpdir
|
tmpdir = testdir.tmpdir
|
||||||
|
@ -50,43 +48,6 @@ class TestClass:
|
||||||
""")
|
""")
|
||||||
l = modcol.collect()
|
l = modcol.collect()
|
||||||
assert len(l) == 0
|
assert len(l) == 0
|
||||||
|
|
||||||
class TestDisabled:
|
|
||||||
def test_disabled_module(self, testdir):
|
|
||||||
modcol = testdir.getmodulecol("""
|
|
||||||
disabled = True
|
|
||||||
def setup_module(mod):
|
|
||||||
raise ValueError
|
|
||||||
def test_method():
|
|
||||||
pass
|
|
||||||
""")
|
|
||||||
l = modcol.collect()
|
|
||||||
assert len(l) == 1
|
|
||||||
py.test.raises(Skipped, "modcol.setup()")
|
|
||||||
|
|
||||||
def test_disabled_class(self, testdir):
|
|
||||||
modcol = testdir.getmodulecol("""
|
|
||||||
class TestClass:
|
|
||||||
disabled = True
|
|
||||||
def test_method(self):
|
|
||||||
pass
|
|
||||||
""")
|
|
||||||
l = modcol.collect()
|
|
||||||
assert len(l) == 1
|
|
||||||
modcol = l[0]
|
|
||||||
assert isinstance(modcol, py.test.collect.Class)
|
|
||||||
l = modcol.collect()
|
|
||||||
assert len(l) == 1
|
|
||||||
py.test.raises(Skipped, "modcol.setup()")
|
|
||||||
|
|
||||||
def test_disabled_class_functional(self, testdir):
|
|
||||||
reprec = testdir.inline_runsource("""
|
|
||||||
class TestSimpleClassSetup:
|
|
||||||
disabled = True
|
|
||||||
def test_classlevel(self): pass
|
|
||||||
def test_classlevel2(self): pass
|
|
||||||
""")
|
|
||||||
reprec.assertoutcome(skipped=2)
|
|
||||||
|
|
||||||
if py.std.sys.version_info > (3, 0):
|
if py.std.sys.version_info > (3, 0):
|
||||||
_func_name_attr = "__name__"
|
_func_name_attr = "__name__"
|
||||||
|
|
Loading…
Reference in New Issue