striking config from Node signature

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-06-11 18:23:32 +02:00
parent 6956d1a7e4
commit 3f50470c6a
5 changed files with 18 additions and 20 deletions

View File

@ -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):

View File

@ -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):

View File

@ -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)

View File

@ -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"

View File

@ -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)