fix for python3 - class.__dict__ is now a dict_proxy which doesn't have setdefault() anymore.
--HG-- branch : trunk
This commit is contained in:
parent
7cba3a07af
commit
6f697294b2
|
@ -44,11 +44,13 @@ with classes to apply markers to all its test methods::
|
||||||
class TestClass:
|
class TestClass:
|
||||||
def test_startup(self):
|
def test_startup(self):
|
||||||
...
|
...
|
||||||
|
def test_startup_and_more(self):
|
||||||
|
...
|
||||||
|
|
||||||
This is equivalent to directly applying the decorator to the
|
This is equivalent to directly applying the decorator to the
|
||||||
``test_startup`` function.
|
two test functions.
|
||||||
|
|
||||||
To remain compatible with Python2.5 you can instead set a
|
To remain compatible with Python2.5 you can also set a
|
||||||
``pytestmark`` attribute on a TestClass like this::
|
``pytestmark`` attribute on a TestClass like this::
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
@ -56,7 +58,7 @@ To remain compatible with Python2.5 you can instead set a
|
||||||
class TestClass:
|
class TestClass:
|
||||||
pytestmark = py.test.mark.webtest
|
pytestmark = py.test.mark.webtest
|
||||||
|
|
||||||
or if you need to use multiple markers::
|
or if you need to use multiple markers you can use a list::
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
|
||||||
|
@ -68,7 +70,7 @@ You can also set a module level marker::
|
||||||
import py
|
import py
|
||||||
pytestmark = py.test.mark.webtest
|
pytestmark = py.test.mark.webtest
|
||||||
|
|
||||||
in which case then it will be applied to all functions and
|
in which case it will be applied to all functions and
|
||||||
methods defined in the module.
|
methods defined in the module.
|
||||||
|
|
||||||
Using "-k MARKNAME" to select tests
|
Using "-k MARKNAME" to select tests
|
||||||
|
@ -114,11 +116,14 @@ class MarkDecorator:
|
||||||
if len(args) == 1 and hasattr(func, '__call__') or \
|
if len(args) == 1 and hasattr(func, '__call__') or \
|
||||||
hasattr(func, '__bases__'):
|
hasattr(func, '__bases__'):
|
||||||
if hasattr(func, '__bases__'):
|
if hasattr(func, '__bases__'):
|
||||||
l = func.__dict__.setdefault("pytestmark", [])
|
if hasattr(func, 'pytestmark'):
|
||||||
|
l = func.pytestmark
|
||||||
if not isinstance(l, list):
|
if not isinstance(l, list):
|
||||||
func.pytestmark = [l, self]
|
func.pytestmark = [l, self]
|
||||||
else:
|
else:
|
||||||
l.append(self)
|
l.append(self)
|
||||||
|
else:
|
||||||
|
func.pytestmark = [self]
|
||||||
else:
|
else:
|
||||||
holder = getattr(func, self.markname, None)
|
holder = getattr(func, self.markname, None)
|
||||||
if holder is None:
|
if holder is None:
|
||||||
|
|
Loading…
Reference in New Issue