diff --git a/py/test/collect.py b/py/test/collect.py index 7726c4ee0..b6af621e8 100644 --- a/py/test/collect.py +++ b/py/test/collect.py @@ -25,15 +25,12 @@ class Node(object): - configuration/options for setup/teardown stdout/stderr capturing and execution of test items """ - def __init__(self, name, parent=None, config=None): + def __init__(self, name, parent=None): self.name = name self.parent = parent - if config is None: - config = parent.config - self.config = config + self.config = getattr(parent, 'config', None) self.fspath = getattr(parent, 'fspath', None) - # # note to myself: Pickling is uh. # @@ -281,7 +278,6 @@ class Collector(Node): """ Directory = configproperty('Directory') Module = configproperty('Module') - #DoctestFile = configproperty('DoctestFile') def collect(self): """ returns a list of children (items and collectors) @@ -335,9 +331,9 @@ class Collector(Node): return self.collect_by_name(name) class FSCollector(Collector): - def __init__(self, fspath, parent=None, config=None): + def __init__(self, fspath, parent=None): fspath = py.path.local(fspath) - super(FSCollector, self).__init__(fspath.basename, parent, config=config) + super(FSCollector, self).__init__(fspath.basename, parent) self.fspath = fspath def __getstate__(self): diff --git a/py/test/config.py b/py/test/config.py index b423fbd80..4c468ae19 100644 --- a/py/test/config.py +++ b/py/test/config.py @@ -155,7 +155,8 @@ class Config(object): if pkgpath is None: pkgpath = path.check(file=1) and path.dirpath() or path Dir = self._conftest.rget("Directory", pkgpath) - col = Dir(pkgpath, config=self) + col = Dir(pkgpath) + col.config = self return col._getfsnode(path) def getconftest_pathlist(self, name, path=None): diff --git a/py/test/plugin/pytest_resultlog.py b/py/test/plugin/pytest_resultlog.py index 869cfe80d..49512ad3c 100644 --- a/py/test/plugin/pytest_resultlog.py +++ b/py/test/plugin/pytest_resultlog.py @@ -94,7 +94,7 @@ import os, StringIO def test_generic_path(): from py.__.test.collect import Node, Item, FSCollector - p1 = Node('a', config='dummy') + p1 = Node('a') assert p1.fspath is None p2 = Node('B', parent=p1) p3 = Node('()', parent = p2) @@ -103,7 +103,7 @@ def test_generic_path(): res = generic_path(item) assert res == 'a.B().c' - p0 = FSCollector('proj/test', config='dummy') + p0 = FSCollector('proj/test') p1 = FSCollector('proj/test/a', parent=p0) p2 = Node('B', parent=p1) p3 = Node('()', parent = p2) diff --git a/py/test/pycollect.py b/py/test/pycollect.py index 06d72dac3..67eebc67e 100644 --- a/py/test/pycollect.py +++ b/py/test/pycollect.py @@ -314,9 +314,9 @@ class Function(FunctionMixin, py.test.collect.Item): and executing a Python callable test object. """ _genid = None - def __init__(self, name, parent=None, config=None, args=(), + def __init__(self, name, parent=None, args=(), callspec=None, callobj=_dummy): - super(Function, self).__init__(name, parent, config=config) + super(Function, self).__init__(name, parent) self._args = args if args: assert not callspec, "yielded functions (deprecated) cannot have funcargs" diff --git a/py/test/testing/test_pycollect.py b/py/test/testing/test_pycollect.py index 402ace27a..c52a3cf31 100644 --- a/py/test/testing/test_pycollect.py +++ b/py/test/testing/test_pycollect.py @@ -6,7 +6,8 @@ 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.parseconfig(tmpdir)) + col = py.test.collect.Module(fn) + col.config = testdir.parseconfig(tmpdir) py.test.raises(py.error.ENOENT, col.collect) def test_failing_import(self, testdir): @@ -223,13 +224,13 @@ class TestFunction: def test_function_equality(self, tmpdir): config = py.test.config._reparse([tmpdir]) - f1 = py.test.collect.Function(name="name", config=config, + f1 = py.test.collect.Function(name="name", args=(1,), callobj=isinstance) - f2 = py.test.collect.Function(name="name", config=config, + f2 = py.test.collect.Function(name="name", args=(1,), callobj=callable) assert not f1 == f2 assert f1 != f2 - f3 = py.test.collect.Function(name="name", config=config, + f3 = py.test.collect.Function(name="name", args=(1,2), callobj=callable) assert not f3 == f2 assert f3 != f2 @@ -237,7 +238,7 @@ class TestFunction: assert not f3 == f1 assert f3 != f1 - f1_b = py.test.collect.Function(name="name", config=config, + f1_b = py.test.collect.Function(name="name", args=(1,), callobj=isinstance) assert f1 == f1_b assert not f1 != f1_b @@ -252,9 +253,9 @@ class TestFunction: param = 1 funcargs = {} id = "world" - f5 = py.test.collect.Function(name="name", config=config, + f5 = py.test.collect.Function(name="name", callspec=callspec1, callobj=isinstance) - f5b = py.test.collect.Function(name="name", config=config, + f5b = py.test.collect.Function(name="name", callspec=callspec2, callobj=isinstance) assert f5 != f5b assert not (f5 == f5b)