slightly simplify collection node init
This commit is contained in:
parent
c3ec2718a2
commit
cf8dd64703
|
@ -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']
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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)
|
||||
|
|
2
setup.py
2
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'],
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue