diff --git a/pytest/__init__.py b/pytest/__init__.py index fb6ab2cbd..6d3de93be 100644 --- a/pytest/__init__.py +++ b/pytest/__init__.py @@ -5,7 +5,7 @@ see http://pytest.org for documentation and details (c) Holger Krekel and others, 2004-2010 """ -__version__ = '2.0.0.dev12' +__version__ = '2.0.0.dev14' __all__ = ['config', 'cmdline'] diff --git a/pytest/plugin/pytester.py b/pytest/plugin/pytester.py index 293b300b3..b438afcbd 100644 --- a/pytest/plugin/pytester.py +++ b/pytest/plugin/pytester.py @@ -275,6 +275,7 @@ class TmpTestdir: p.ensure("__init__.py") return p + Collection = Collection def getnode(self, config, arg): collection = Collection(config) return collection.getbyid(collection._normalizearg(arg))[0] diff --git a/pytest/plugin/session.py b/pytest/plugin/session.py index 759b36cff..7628bca10 100644 --- a/pytest/plugin/session.py +++ b/pytest/plugin/session.py @@ -324,7 +324,7 @@ class Node(object): self.config = config or parent.config #: the collection this node is part of. - self.collection = collection or getattr(parent, 'collection', None) + self.collection = collection or parent.collection #: the file where this item is contained/collected from. self.fspath = getattr(parent, 'fspath', None) diff --git a/setup.py b/setup.py index 8e0ab15cf..9deaaf49a 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.0.0.dev12', + version='2.0.0.dev14', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/plugin/test_python.py b/testing/plugin/test_python.py index b5f344c1d..2efbd5b07 100644 --- a/testing/plugin/test_python.py +++ b/testing/plugin/test_python.py @@ -5,7 +5,10 @@ class TestModule: def test_module_file_not_found(self, testdir): tmpdir = testdir.tmpdir fn = tmpdir.join('nada','no') - col = py.test.collect.Module(fn, config=testdir.Config()) + config=testdir.Config() + config.args = ["hello"] + col = py.test.collect.Module(fn, config=config, + collection=testdir.Collection(config)) col.config = testdir.parseconfig(tmpdir) py.test.raises(py.error.ENOENT, col.collect) @@ -212,14 +215,15 @@ class TestFunction: def test_function_equality(self, testdir, tmpdir): config = testdir.reparseconfig() + collection = testdir.Collection(config) f1 = py.test.collect.Function(name="name", config=config, - args=(1,), callobj=isinstance) + args=(1,), callobj=isinstance, collection=collection) f2 = py.test.collect.Function(name="name",config=config, - args=(1,), callobj=py.builtin.callable) + args=(1,), callobj=py.builtin.callable, collection=collection) assert not f1 == f2 assert f1 != f2 f3 = py.test.collect.Function(name="name", config=config, - args=(1,2), callobj=py.builtin.callable) + args=(1,2), callobj=py.builtin.callable, collection=collection) assert not f3 == f2 assert f3 != f2 @@ -227,7 +231,7 @@ class TestFunction: assert f3 != f1 f1_b = py.test.collect.Function(name="name", config=config, - args=(1,), callobj=isinstance) + args=(1,), callobj=isinstance, collection=collection) assert f1 == f1_b assert not f1 != f1_b