(experimental) allow cmdline arguments to deep-point to a test, also remove virtually redundant session.getinitialitems() calls

--HG--
branch : trunk
This commit is contained in:
holger krekel 2010-01-10 21:29:36 +01:00
parent 3029aa6558
commit 99301a0dae
13 changed files with 110 additions and 83 deletions

View File

@ -13,7 +13,8 @@ def main(args=None):
config.parse(args) config.parse(args)
config.pluginmanager.do_configure(config) config.pluginmanager.do_configure(config)
session = config.initsession() session = config.initsession()
exitstatus = session.main() colitems = config.getinitialnodes()
exitstatus = session.main(colitems)
config.pluginmanager.do_unconfigure(config) config.pluginmanager.do_unconfigure(config)
raise SystemExit(exitstatus) raise SystemExit(exitstatus)
except config.Error: except config.Error:

View File

@ -383,24 +383,10 @@ class RootCollector(Directory):
Directory.__init__(self, config.topdir, parent=None, config=config) Directory.__init__(self, config.topdir, parent=None, config=config)
self.name = None self.name = None
def getfsnode(self, path):
path = py.path.local(path)
if not path.check():
raise self.config.Error("file not found: %s" %(path,))
topdir = self.config.topdir
if path != topdir and not path.relto(topdir):
raise self.config.Error("path %r is not relative to %r" %
(str(path), str(self.fspath)))
# assumtion: pytest's fs-collector tree follows the filesystem tree
basenames = filter(None, path.relto(topdir).split(path.sep))
try:
return self.getbynames(basenames)
except ValueError:
raise self.config.Error("can't collect: %s" % str(path))
def getbynames(self, names): def getbynames(self, names):
current = self.consider(self.config.topdir) current = self.consider(self.config.topdir)
for name in names: while names:
name = names.pop(0)
if name == ".": # special "identity" name if name == ".": # special "identity" name
continue continue
l = [] l = []
@ -409,8 +395,12 @@ class RootCollector(Directory):
l.append(x) l.append(x)
elif x.fspath == current.fspath.join(name): elif x.fspath == current.fspath.join(name):
l.append(x) l.append(x)
elif x.name == "()":
names.insert(0, name)
l.append(x)
break
if not l: if not l:
raise ValueError("no node named %r in %r" %(name, current)) raise ValueError("no node named %r below %r" %(name, current))
current = l[0] current = l[0]
return current return current

View File

@ -99,7 +99,11 @@ class Config(object):
args.append(py.std.os.getcwd()) args.append(py.std.os.getcwd())
self.topdir = gettopdir(args) self.topdir = gettopdir(args)
self._rootcol = RootCollector(config=self) self._rootcol = RootCollector(config=self)
self.args = [py.path.local(x) for x in args] self._setargs(args)
def _setargs(self, args):
self.args = list(args)
self._argfspaths = [py.path.local(decodearg(x)[0]) for x in args]
# config objects are usually pickled across system # config objects are usually pickled across system
# barriers but they contain filesystem paths. # barriers but they contain filesystem paths.
@ -121,10 +125,10 @@ class Config(object):
self.__init__(topdir=py.path.local()) self.__init__(topdir=py.path.local())
self._rootcol = RootCollector(config=self) self._rootcol = RootCollector(config=self)
args, cmdlineopts = repr args, cmdlineopts = repr
args = [self.topdir.join(x) for x in args] args = [str(self.topdir.join(x)) for x in args]
self.option = cmdlineopts self.option = cmdlineopts
self._preparse(args) self._preparse(args)
self.args = args self._setargs(args)
def ensuretemp(self, string, dir=True): def ensuretemp(self, string, dir=True):
return self.getbasetemp().ensure(string, dir=dir) return self.getbasetemp().ensure(string, dir=dir)
@ -149,11 +153,26 @@ class Config(object):
return py.path.local.make_numbered_dir(prefix=basename + "-", return py.path.local.make_numbered_dir(prefix=basename + "-",
keep=0, rootdir=basetemp, lock_timeout=None) keep=0, rootdir=basetemp, lock_timeout=None)
def getcolitems(self): def getinitialnodes(self):
return [self.getfsnode(arg) for arg in self.args] return [self.getnode(arg) for arg in self.args]
def getfsnode(self, path): def getnode(self, arg):
return self._rootcol.getfsnode(path) parts = decodearg(arg)
path = py.path.local(parts.pop(0))
if not path.check():
raise self.Error("file not found: %s" %(path,))
topdir = self.topdir
if path != topdir and not path.relto(topdir):
raise self.Error("path %r is not relative to %r" %
(str(path), str(topdir)))
# assumtion: pytest's fs-collector tree follows the filesystem tree
names = filter(None, path.relto(topdir).split(path.sep))
names.extend(parts)
try:
return self._rootcol.getbynames(names)
except ValueError:
e = py.std.sys.exc_info()[1]
raise self.Error("can't collect: %s\n%s" % (arg, e.args[0]))
def _getcollectclass(self, name, path): def _getcollectclass(self, name, path):
try: try:
@ -282,11 +301,11 @@ def gettopdir(args):
if the common base dir resides in a python package if the common base dir resides in a python package
parent directory of the root package is returned. parent directory of the root package is returned.
""" """
args = [py.path.local(arg) for arg in args] fsargs = [py.path.local(decodearg(arg)[0]) for arg in args]
p = args and args[0] or None p = fsargs and fsargs[0] or None
for x in args[1:]: for x in fsargs[1:]:
p = p.common(x) p = p.common(x)
assert p, "cannot determine common basedir of %s" %(args,) assert p, "cannot determine common basedir of %s" %(fsargs,)
pkgdir = p.pypkgpath() pkgdir = p.pypkgpath()
if pkgdir is None: if pkgdir is None:
if p.check(file=1): if p.check(file=1):
@ -295,6 +314,10 @@ def gettopdir(args):
else: else:
return pkgdir.dirpath() return pkgdir.dirpath()
def decodearg(arg):
arg = str(arg)
return arg.split("::")
def onpytestaccess(): def onpytestaccess():
# it's enough to have our containing module loaded as # it's enough to have our containing module loaded as
# it initializes a per-process config instance # it initializes a per-process config instance

View File

@ -85,8 +85,7 @@ class DSession(Session):
# raise config.Error("dist mode %r needs test execution environments, " # raise config.Error("dist mode %r needs test execution environments, "
# "none found." %(config.option.dist)) # "none found." %(config.option.dist))
def main(self, colitems=None): def main(self, colitems):
colitems = self.getinitialitems(colitems)
self.sessionstarts() self.sessionstarts()
self.setup() self.setup()
exitstatus = self.loop(colitems) exitstatus = self.loop(colitems)

View File

@ -142,7 +142,7 @@ def slave_runsession(channel, config, fullwidth, hasmarkup):
continue continue
colitems.append(colitem) colitems.append(colitem)
else: else:
colitems = None colitems = config.getinitialnodes()
session.shouldclose = channel.isclosed session.shouldclose = channel.isclosed
class Failures(list): class Failures(list):

View File

@ -93,15 +93,8 @@ class Session(object):
exitstatus=exitstatus, exitstatus=exitstatus,
) )
def getinitialitems(self, colitems): def main(self, colitems):
if colitems is None:
colitems = [self.config.getfsnode(arg)
for arg in self.config.args]
return colitems
def main(self, colitems=None):
""" main loop for running tests. """ """ main loop for running tests. """
colitems = self.getinitialitems(colitems)
self.shouldstop = False self.shouldstop = False
self.sessionstarts() self.sessionstarts()
exitstatus = outcome.EXIT_OK exitstatus = outcome.EXIT_OK

View File

@ -26,7 +26,7 @@ def pytest_collect_file(path, parent):
ext = path.ext ext = path.ext
pb = path.purebasename pb = path.purebasename
if pb.startswith("test_") or pb.endswith("_test") or \ if pb.startswith("test_") or pb.endswith("_test") or \
path in parent.config.args: path in parent.config._argfspaths:
if ext == ".py": if ext == ".py":
return parent.Module(path, parent=parent) return parent.Module(path, parent=parent)
@ -41,7 +41,7 @@ def pytest_collect_directory(path, parent):
# define Directory(dir) already # define Directory(dir) already
if not parent.recfilter(path): # by default special ".cvs", ... if not parent.recfilter(path): # by default special ".cvs", ...
# check if cmdline specified this dir or a subdir directly # check if cmdline specified this dir or a subdir directly
for arg in parent.config.args: for arg in parent.config._argfspaths:
if path == arg or arg.relto(path): if path == arg or arg.relto(path):
break break
else: else:

View File

@ -158,7 +158,7 @@ class TmpTestdir:
config = self.parseconfig(*args) config = self.parseconfig(*args)
session = config.initsession() session = config.initsession()
rec = self.getreportrecorder(config) rec = self.getreportrecorder(config)
colitems = [config.getfsnode(arg) for arg in config.args] colitems = [config.getnode(arg) for arg in config.args]
items = list(session.genitems(colitems)) items = list(session.genitems(colitems))
return items, rec return items, rec
@ -190,7 +190,8 @@ class TmpTestdir:
config.pluginmanager.do_configure(config) config.pluginmanager.do_configure(config)
session = config.initsession() session = config.initsession()
reprec = self.getreportrecorder(config) reprec = self.getreportrecorder(config)
session.main() colitems = config.getinitialnodes()
session.main(colitems)
config.pluginmanager.do_unconfigure(config) config.pluginmanager.do_unconfigure(config)
return reprec return reprec
@ -251,7 +252,7 @@ class TmpTestdir:
def getfscol(self, path, configargs=()): def getfscol(self, path, configargs=()):
self.config = self.parseconfig(path, *configargs) self.config = self.parseconfig(path, *configargs)
self.session = self.config.initsession() self.session = self.config.initsession()
return self.config.getfsnode(path) return self.config.getnode(path)
def getmodulecol(self, source, configargs=(), withinit=False): def getmodulecol(self, source, configargs=(), withinit=False):
kw = {self.request.function.__name__: py.code.Source(source).strip()} kw = {self.request.function.__name__: py.code.Source(source).strip()}
@ -266,7 +267,7 @@ class TmpTestdir:
plugin = self.config.pluginmanager.getplugin("runner") plugin = self.config.pluginmanager.getplugin("runner")
plugin.pytest_configure(config=self.config) plugin.pytest_configure(config=self.config)
return self.config.getfsnode(path) return self.config.getnode(path)
def popen(self, cmdargs, stdout, stderr, **kw): def popen(self, cmdargs, stdout, stderr, **kw):
if not hasattr(py.std, 'subprocess'): if not hasattr(py.std, 'subprocess'):

View File

@ -396,7 +396,7 @@ class TestDSession:
config = testdir.parseconfig('-d', p1, '--tx=popen') config = testdir.parseconfig('-d', p1, '--tx=popen')
dsession = DSession(config) dsession = DSession(config)
hookrecorder = testdir.getreportrecorder(config).hookrecorder hookrecorder = testdir.getreportrecorder(config).hookrecorder
dsession.main([config.getfsnode(p1)]) dsession.main([config.getnode(p1)])
rep = hookrecorder.popcall("pytest_runtest_logreport").report rep = hookrecorder.popcall("pytest_runtest_logreport").report
assert rep.passed assert rep.passed
rep = hookrecorder.popcall("pytest_runtest_logreport").report rep = hookrecorder.popcall("pytest_runtest_logreport").report

View File

@ -66,7 +66,7 @@ class TestCollector:
return MyDirectory(path, parent=parent) return MyDirectory(path, parent=parent)
""") """)
config = testdir.parseconfig(hello) config = testdir.parseconfig(hello)
node = config.getfsnode(hello) node = config.getnode(hello)
assert isinstance(node, py.test.collect.File) assert isinstance(node, py.test.collect.File)
assert node.name == "hello.xxx" assert node.name == "hello.xxx"
names = config._rootcol.totrail(node) names = config._rootcol.totrail(node)
@ -84,7 +84,7 @@ class TestCollectFS:
tmpdir.ensure("normal", 'test_found.py') tmpdir.ensure("normal", 'test_found.py')
tmpdir.ensure('test_found.py') tmpdir.ensure('test_found.py')
col = testdir.parseconfig(tmpdir).getfsnode(tmpdir) col = testdir.parseconfig(tmpdir).getnode(tmpdir)
items = col.collect() items = col.collect()
names = [x.name for x in items] names = [x.name for x in items]
assert len(items) == 2 assert len(items) == 2
@ -93,7 +93,7 @@ class TestCollectFS:
def test_found_certain_testfiles(self, testdir): def test_found_certain_testfiles(self, testdir):
p1 = testdir.makepyfile(test_found = "pass", found_test="pass") p1 = testdir.makepyfile(test_found = "pass", found_test="pass")
col = testdir.parseconfig(p1).getfsnode(p1.dirpath()) col = testdir.parseconfig(p1).getnode(p1.dirpath())
items = col.collect() # Directory collect returns files sorted by name items = col.collect() # Directory collect returns files sorted by name
assert len(items) == 2 assert len(items) == 2
assert items[1].name == 'test_found.py' assert items[1].name == 'test_found.py'
@ -106,7 +106,7 @@ class TestCollectFS:
testdir.makepyfile(test_two="hello") testdir.makepyfile(test_two="hello")
p1.dirpath().mkdir("dir2") p1.dirpath().mkdir("dir2")
config = testdir.parseconfig() config = testdir.parseconfig()
col = config.getfsnode(p1.dirpath()) col = config.getnode(p1.dirpath())
names = [x.name for x in col.collect()] names = [x.name for x in col.collect()]
assert names == ["dir1", "dir2", "test_one.py", "test_two.py", "x"] assert names == ["dir1", "dir2", "test_one.py", "test_two.py", "x"]
@ -120,7 +120,7 @@ class TestCollectPluginHookRelay:
config = testdir.Config() config = testdir.Config()
config.pluginmanager.register(Plugin()) config.pluginmanager.register(Plugin())
config.parse([tmpdir]) config.parse([tmpdir])
col = config.getfsnode(tmpdir) col = config.getnode(tmpdir)
testdir.makefile(".abc", "xyz") testdir.makefile(".abc", "xyz")
res = col.collect() res = col.collect()
assert len(wascalled) == 1 assert len(wascalled) == 1
@ -203,20 +203,36 @@ class TestRootCol:
tmpdir.ensure("a", "__init__.py") tmpdir.ensure("a", "__init__.py")
x = tmpdir.ensure("a", "trail.py") x = tmpdir.ensure("a", "trail.py")
config = testdir.reparseconfig([x]) config = testdir.reparseconfig([x])
col = config.getfsnode(x) col = config.getnode(x)
trail = config._rootcol.totrail(col) trail = config._rootcol.totrail(col)
col2 = config._rootcol.fromtrail(trail) col2 = config._rootcol.fromtrail(trail)
assert col2 == col assert col2 == col
def test_totrail_topdir_and_beyond(self, testdir, tmpdir): def test_totrail_topdir_and_beyond(self, testdir, tmpdir):
config = testdir.reparseconfig() config = testdir.reparseconfig()
col = config.getfsnode(config.topdir) col = config.getnode(config.topdir)
trail = config._rootcol.totrail(col) trail = config._rootcol.totrail(col)
col2 = config._rootcol.fromtrail(trail) col2 = config._rootcol.fromtrail(trail)
assert col2.fspath == config.topdir assert col2.fspath == config.topdir
assert len(col2.listchain()) == 1 assert len(col2.listchain()) == 1
py.test.raises(config.Error, "config.getfsnode(config.topdir.dirpath())") py.test.raises(config.Error, "config.getnode(config.topdir.dirpath())")
#col3 = config.getfsnode(config.topdir.dirpath()) #col3 = config.getnode(config.topdir.dirpath())
#py.test.raises(ValueError, #py.test.raises(ValueError,
# "col3._totrail()") # "col3._totrail()")
def test_argid(self, testdir, tmpdir):
cfg = testdir.parseconfig()
p = testdir.makepyfile("def test_func(): pass")
item = cfg.getnode("%s::test_func" % p)
assert item.name == "test_func"
def test_argid_with_method(self, testdir, tmpdir):
cfg = testdir.parseconfig()
p = testdir.makepyfile("""
class TestClass:
def test_method(self): pass
""")
item = cfg.getnode("%s::TestClass::()::test_method" % p)
assert item.name == "test_method"
item = cfg.getnode("%s::TestClass::test_method" % p)
assert item.name == "test_method"

View File

@ -117,28 +117,28 @@ class TestConfigAPI:
py.test.raises(ValueError, "config.setsessionclass(Session1)") py.test.raises(ValueError, "config.setsessionclass(Session1)")
class TestConfigApi_getcolitems: class TestConfigApi_getinitialnodes:
def test_getcolitems_onedir(self, testdir): def test_onedir(self, testdir):
config = testdir.reparseconfig([testdir.tmpdir]) config = testdir.reparseconfig([testdir.tmpdir])
colitems = config.getcolitems() colitems = config.getinitialnodes()
assert len(colitems) == 1 assert len(colitems) == 1
col = colitems[0] col = colitems[0]
assert isinstance(col, py.test.collect.Directory) assert isinstance(col, py.test.collect.Directory)
for col in col.listchain(): for col in col.listchain():
assert col.config is config assert col.config is config
def test_getcolitems_twodirs(self, testdir, tmpdir): def test_twodirs(self, testdir, tmpdir):
config = testdir.reparseconfig([tmpdir, tmpdir]) config = testdir.reparseconfig([tmpdir, tmpdir])
colitems = config.getcolitems() colitems = config.getinitialnodes()
assert len(colitems) == 2 assert len(colitems) == 2
col1, col2 = colitems col1, col2 = colitems
assert col1.name == col2.name assert col1.name == col2.name
assert col1.parent == col2.parent assert col1.parent == col2.parent
def test_getcolitems_curdir_and_subdir(self, testdir, tmpdir): def test_curdir_and_subdir(self, testdir, tmpdir):
a = tmpdir.ensure("a", dir=1) a = tmpdir.ensure("a", dir=1)
config = testdir.reparseconfig([tmpdir, a]) config = testdir.reparseconfig([tmpdir, a])
colitems = config.getcolitems() colitems = config.getinitialnodes()
assert len(colitems) == 2 assert len(colitems) == 2
col1, col2 = colitems col1, col2 = colitems
assert col1.name == tmpdir.basename assert col1.name == tmpdir.basename
@ -147,10 +147,10 @@ class TestConfigApi_getcolitems:
for subcol in col.listchain(): for subcol in col.listchain():
assert col.config is config assert col.config is config
def test__getcol_global_file(self, testdir, tmpdir): def test_global_file(self, testdir, tmpdir):
x = tmpdir.ensure("x.py") x = tmpdir.ensure("x.py")
config = testdir.reparseconfig([x]) config = testdir.reparseconfig([x])
col = config.getfsnode(x) col, = config.getinitialnodes()
assert isinstance(col, py.test.collect.Module) assert isinstance(col, py.test.collect.Module)
assert col.name == 'x.py' assert col.name == 'x.py'
assert col.parent.name == tmpdir.basename assert col.parent.name == tmpdir.basename
@ -158,21 +158,21 @@ class TestConfigApi_getcolitems:
for col in col.listchain(): for col in col.listchain():
assert col.config is config assert col.config is config
def test__getcol_global_dir(self, testdir, tmpdir): def test_global_dir(self, testdir, tmpdir):
x = tmpdir.ensure("a", dir=1) x = tmpdir.ensure("a", dir=1)
config = testdir.reparseconfig([x]) config = testdir.reparseconfig([x])
col = config.getfsnode(x) col, = config.getinitialnodes()
assert isinstance(col, py.test.collect.Directory) assert isinstance(col, py.test.collect.Directory)
print(col.listchain()) print(col.listchain())
assert col.name == 'a' assert col.name == 'a'
assert isinstance(col.parent, RootCollector) assert isinstance(col.parent, RootCollector)
assert col.config is config assert col.config is config
def test__getcol_pkgfile(self, testdir, tmpdir): def test_pkgfile(self, testdir, tmpdir):
x = tmpdir.ensure("x.py") x = tmpdir.ensure("x.py")
tmpdir.ensure("__init__.py") tmpdir.ensure("__init__.py")
config = testdir.reparseconfig([x]) config = testdir.reparseconfig([x])
col = config.getfsnode(x) col, = config.getinitialnodes()
assert isinstance(col, py.test.collect.Module) assert isinstance(col, py.test.collect.Module)
assert col.name == 'x.py' assert col.name == 'x.py'
assert col.parent.name == x.dirpath().basename assert col.parent.name == x.dirpath().basename
@ -214,7 +214,9 @@ class TestConfig_gettopdir:
Z = tmp.ensure('Z', dir=1) Z = tmp.ensure('Z', dir=1)
assert gettopdir([c]) == a assert gettopdir([c]) == a
assert gettopdir([c, Z]) == tmp assert gettopdir([c, Z]) == tmp
assert gettopdir(["%s::xyc" % c]) == a
assert gettopdir(["%s::xyc::abc" % c]) == a
assert gettopdir(["%s::xyc" % c, "%s::abc" % Z]) == tmp
def test_options_on_small_file_do_not_blow_up(testdir): def test_options_on_small_file_do_not_blow_up(testdir):
def runfiletest(opts): def runfiletest(opts):

View File

@ -50,7 +50,7 @@ class TestCollectDeprecated:
def check2(self): pass def check2(self): pass
""")) """))
config = testdir.parseconfig(somefile) config = testdir.parseconfig(somefile)
dirnode = config.getfsnode(somefile.dirpath()) dirnode = config.getnode(somefile.dirpath())
colitems = dirnode.collect() colitems = dirnode.collect()
w = recwarn.pop(DeprecationWarning) w = recwarn.pop(DeprecationWarning)
assert w.filename.find("conftest.py") != -1 assert w.filename.find("conftest.py") != -1
@ -174,7 +174,7 @@ class TestCollectDeprecated:
""") """)
testme = testdir.makefile('xxx', testme="hello") testme = testdir.makefile('xxx', testme="hello")
config = testdir.parseconfig(testme) config = testdir.parseconfig(testme)
col = config.getfsnode(testme) col = config.getnode(testme)
assert col.collect() == [] assert col.collect() == []
@ -236,11 +236,11 @@ class TestDisabled:
""") """)
config = testdir.parseconfig() config = testdir.parseconfig()
if name == "Directory": if name == "Directory":
config.getfsnode(testdir.tmpdir) config.getnode(testdir.tmpdir)
elif name in ("Module", "File"): elif name in ("Module", "File"):
config.getfsnode(p) config.getnode(p)
else: else:
fnode = config.getfsnode(p) fnode = config.getnode(p)
recwarn.clear() recwarn.clear()
fnode.collect() fnode.collect()
w = recwarn.pop(DeprecationWarning) w = recwarn.pop(DeprecationWarning)
@ -317,7 +317,7 @@ def test_conftest_non_python_items(recwarn, testdir):
testdir.maketxtfile(x="") testdir.maketxtfile(x="")
config = testdir.parseconfig() config = testdir.parseconfig()
recwarn.clear() recwarn.clear()
dircol = config.getfsnode(checkfile.dirpath()) dircol = config.getnode(checkfile.dirpath())
w = recwarn.pop(DeprecationWarning) w = recwarn.pop(DeprecationWarning)
assert str(w.message).find("conftest.py") != -1 assert str(w.message).find("conftest.py") != -1
colitems = dircol.collect() colitems = dircol.collect()
@ -325,7 +325,7 @@ def test_conftest_non_python_items(recwarn, testdir):
assert colitems[0].name == "hello.xxx" assert colitems[0].name == "hello.xxx"
assert colitems[0].__class__.__name__ == "CustomItem" assert colitems[0].__class__.__name__ == "CustomItem"
item = config.getfsnode(checkfile) item = config.getnode(checkfile)
assert item.name == "hello.xxx" assert item.name == "hello.xxx"
assert item.__class__.__name__ == "CustomItem" assert item.__class__.__name__ == "CustomItem"
@ -358,14 +358,14 @@ def test_extra_python_files_and_functions(testdir):
""") """)
# check that directory collects "check_" files # check that directory collects "check_" files
config = testdir.parseconfig() config = testdir.parseconfig()
col = config.getfsnode(checkfile.dirpath()) col = config.getnode(checkfile.dirpath())
colitems = col.collect() colitems = col.collect()
assert len(colitems) == 1 assert len(colitems) == 1
assert isinstance(colitems[0], py.test.collect.Module) assert isinstance(colitems[0], py.test.collect.Module)
# check that module collects "check_" functions and methods # check that module collects "check_" functions and methods
config = testdir.parseconfig(checkfile) config = testdir.parseconfig(checkfile)
col = config.getfsnode(checkfile) col = config.getnode(checkfile)
assert isinstance(col, py.test.collect.Module) assert isinstance(col, py.test.collect.Module)
colitems = col.collect() colitems = col.collect()
assert len(colitems) == 2 assert len(colitems) == 2

View File

@ -75,8 +75,10 @@ class TestConfigPickling:
config2 = Config() config2 = Config()
config2.__setstate__(config1.__getstate__()) config2.__setstate__(config1.__getstate__())
assert config2.topdir == py.path.local() assert config2.topdir == py.path.local()
config2_relpaths = [x.relto(config2.topdir) for x in config2.args] config2_relpaths = [py.path.local(x).relto(config2.topdir)
config1_relpaths = [x.relto(config1.topdir) for x in config1.args] for x in config2.args]
config1_relpaths = [py.path.local(x).relto(config1.topdir)
for x in config1.args]
assert config2_relpaths == config1_relpaths assert config2_relpaths == config1_relpaths
for name, value in config1.option.__dict__.items(): for name, value in config1.option.__dict__.items():
@ -138,7 +140,7 @@ class TestConfigPickling:
testdir.chdir() testdir.chdir()
testdir.makepyfile(hello="def test_x(): pass") testdir.makepyfile(hello="def test_x(): pass")
config = testdir.parseconfig(tmpdir) config = testdir.parseconfig(tmpdir)
col = config.getfsnode(config.topdir) col = config.getnode(config.topdir)
io = py.io.BytesIO() io = py.io.BytesIO()
pickler = pickle.Pickler(io) pickler = pickle.Pickler(io)
pickler.dump(col) pickler.dump(col)
@ -152,7 +154,7 @@ class TestConfigPickling:
tmpdir = testdir.tmpdir tmpdir = testdir.tmpdir
dir1 = tmpdir.ensure("somedir", dir=1) dir1 = tmpdir.ensure("somedir", dir=1)
config = testdir.parseconfig() config = testdir.parseconfig()
col = config.getfsnode(config.topdir) col = config.getnode(config.topdir)
col1 = col.join(dir1.basename) col1 = col.join(dir1.basename)
assert col1.parent is col assert col1.parent is col
io = py.io.BytesIO() io = py.io.BytesIO()