2008-08-16 23:26:59 +08:00
|
|
|
import py
|
2010-01-14 00:15:54 +08:00
|
|
|
from py._test.collect import RootCollector
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-03-17 05:17:14 +08:00
|
|
|
|
2009-02-27 18:18:27 +08:00
|
|
|
class TestConfigCmdlineParsing:
|
2009-03-02 19:14:59 +08:00
|
|
|
def test_parser_addoption_default_env(self, testdir, monkeypatch):
|
|
|
|
import os
|
|
|
|
config = testdir.Config()
|
2009-10-27 17:03:11 +08:00
|
|
|
group = config._parser.getgroup("hello")
|
2009-03-02 19:14:59 +08:00
|
|
|
|
|
|
|
monkeypatch.setitem(os.environ, 'PYTEST_OPTION_OPTION1', 'True')
|
|
|
|
group.addoption("--option1", action="store_true")
|
|
|
|
assert group.options[0].default == True
|
|
|
|
|
|
|
|
monkeypatch.setitem(os.environ, 'PYTEST_OPTION_OPTION2', 'abc')
|
|
|
|
group.addoption("--option2", action="store", default="x")
|
|
|
|
assert group.options[1].default == "abc"
|
|
|
|
|
|
|
|
monkeypatch.setitem(os.environ, 'PYTEST_OPTION_OPTION3', '32')
|
|
|
|
group.addoption("--option3", action="store", type="int")
|
|
|
|
assert group.options[2].default == 32
|
|
|
|
|
|
|
|
group.addoption("--option4", action="store", type="int")
|
|
|
|
assert group.options[3].default == ("NO", "DEFAULT")
|
|
|
|
|
2009-03-17 14:10:40 +08:00
|
|
|
def test_parser_addoption_default_conftest(self, testdir, monkeypatch):
|
|
|
|
import os
|
2009-08-19 21:45:01 +08:00
|
|
|
testdir.makeconftest("option_verbose=True")
|
2009-03-17 14:10:40 +08:00
|
|
|
config = testdir.parseconfig()
|
|
|
|
assert config.option.verbose
|
|
|
|
|
2009-12-30 01:02:54 +08:00
|
|
|
def test_parsing_again_fails(self, testdir):
|
|
|
|
config = testdir.reparseconfig([testdir.tmpdir])
|
2009-02-27 18:18:27 +08:00
|
|
|
py.test.raises(AssertionError, "config.parse([])")
|
2008-08-16 23:26:59 +08:00
|
|
|
|
|
|
|
|
2009-03-17 20:42:40 +08:00
|
|
|
class TestConfigTmpdir:
|
|
|
|
def test_getbasetemp(self, testdir):
|
|
|
|
config = testdir.Config()
|
|
|
|
config.basetemp = "hello"
|
|
|
|
config.getbasetemp() == "hello"
|
|
|
|
|
|
|
|
def test_mktemp(self, testdir):
|
|
|
|
config = testdir.Config()
|
|
|
|
config.basetemp = testdir.mkdir("hello")
|
|
|
|
tmp = config.mktemp("world")
|
|
|
|
assert tmp.relto(config.basetemp) == "world"
|
|
|
|
tmp = config.mktemp("this", numbered=True)
|
|
|
|
assert tmp.relto(config.basetemp).startswith("this")
|
|
|
|
tmp2 = config.mktemp("this", numbered=True)
|
|
|
|
assert tmp2.relto(config.basetemp).startswith("this")
|
|
|
|
assert tmp2 != tmp
|
|
|
|
|
|
|
|
def test_reparse(self, testdir):
|
2009-12-30 01:02:54 +08:00
|
|
|
config2 = testdir.reparseconfig([])
|
|
|
|
config3 = testdir.reparseconfig([])
|
|
|
|
assert config2.getbasetemp() != config3.getbasetemp()
|
|
|
|
assert not config2.getbasetemp().relto(config3.getbasetemp())
|
|
|
|
assert not config3.getbasetemp().relto(config2.getbasetemp())
|
2009-03-17 20:42:40 +08:00
|
|
|
|
2009-02-27 18:18:27 +08:00
|
|
|
class TestConfigAPI:
|
2009-06-18 23:19:12 +08:00
|
|
|
|
2009-02-27 18:18:27 +08:00
|
|
|
def test_config_getvalue_honours_conftest(self, testdir):
|
|
|
|
testdir.makepyfile(conftest="x=1")
|
|
|
|
testdir.mkdir("sub").join("conftest.py").write("x=2 ; y = 3")
|
|
|
|
config = testdir.parseconfig()
|
|
|
|
o = testdir.tmpdir
|
|
|
|
assert config.getvalue("x") == 1
|
|
|
|
assert config.getvalue("x", o.join('sub')) == 2
|
|
|
|
py.test.raises(KeyError, "config.getvalue('y')")
|
2009-12-30 01:02:54 +08:00
|
|
|
config = testdir.reparseconfig([str(o.join('sub'))])
|
2009-02-27 18:18:27 +08:00
|
|
|
assert config.getvalue("x") == 2
|
|
|
|
assert config.getvalue("y") == 3
|
|
|
|
assert config.getvalue("x", o) == 1
|
|
|
|
py.test.raises(KeyError, 'config.getvalue("y", o)')
|
|
|
|
|
2009-03-02 19:14:59 +08:00
|
|
|
def test_config_getvalueorskip(self, testdir):
|
|
|
|
config = testdir.parseconfig()
|
2010-04-28 14:42:56 +08:00
|
|
|
py.test.raises(py.test.skip.Exception,
|
2010-04-28 03:13:09 +08:00
|
|
|
"config.getvalueorskip('hello')")
|
2009-03-02 19:14:59 +08:00
|
|
|
verbose = config.getvalueorskip("verbose")
|
|
|
|
assert verbose == config.option.verbose
|
|
|
|
config.option.hello = None
|
2010-04-28 14:42:56 +08:00
|
|
|
py.test.raises(py.test.skip.Exception,
|
2010-04-28 03:13:09 +08:00
|
|
|
"config.getvalueorskip('hello')")
|
2009-03-02 19:14:59 +08:00
|
|
|
|
2009-02-27 18:18:27 +08:00
|
|
|
def test_config_overwrite(self, testdir):
|
|
|
|
o = testdir.tmpdir
|
|
|
|
o.ensure("conftest.py").write("x=1")
|
2009-12-30 01:02:54 +08:00
|
|
|
config = testdir.reparseconfig([str(o)])
|
2009-02-27 18:18:27 +08:00
|
|
|
assert config.getvalue('x') == 1
|
|
|
|
config.option.x = 2
|
|
|
|
assert config.getvalue('x') == 2
|
2009-12-30 01:02:54 +08:00
|
|
|
config = testdir.reparseconfig([str(o)])
|
2009-02-27 18:18:27 +08:00
|
|
|
assert config.getvalue('x') == 1
|
|
|
|
|
2009-12-30 01:02:54 +08:00
|
|
|
def test_getconftest_pathlist(self, testdir, tmpdir):
|
2009-02-27 18:18:27 +08:00
|
|
|
somepath = tmpdir.join("x", "y", "z")
|
|
|
|
p = tmpdir.join("conftest.py")
|
|
|
|
p.write("pathlist = ['.', %r]" % str(somepath))
|
2009-12-30 01:02:54 +08:00
|
|
|
config = testdir.reparseconfig([p])
|
2009-03-17 05:17:14 +08:00
|
|
|
assert config.getconftest_pathlist('notexist') is None
|
|
|
|
pl = config.getconftest_pathlist('pathlist')
|
2009-08-30 02:04:48 +08:00
|
|
|
print(pl)
|
2009-02-27 18:18:27 +08:00
|
|
|
assert len(pl) == 2
|
|
|
|
assert pl[0] == tmpdir
|
|
|
|
assert pl[1] == somepath
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-02-28 05:32:49 +08:00
|
|
|
def test_setsessionclass_and_initsession(self, testdir):
|
2009-04-07 22:27:57 +08:00
|
|
|
config = testdir.Config()
|
2009-02-28 05:32:49 +08:00
|
|
|
class Session1:
|
|
|
|
def __init__(self, config):
|
|
|
|
self.config = config
|
|
|
|
config.setsessionclass(Session1)
|
|
|
|
session = config.initsession()
|
|
|
|
assert isinstance(session, Session1)
|
|
|
|
assert session.config is config
|
|
|
|
py.test.raises(ValueError, "config.setsessionclass(Session1)")
|
|
|
|
|
|
|
|
|
2010-01-11 04:29:36 +08:00
|
|
|
class TestConfigApi_getinitialnodes:
|
|
|
|
def test_onedir(self, testdir):
|
2009-12-30 01:02:54 +08:00
|
|
|
config = testdir.reparseconfig([testdir.tmpdir])
|
2010-01-11 04:29:36 +08:00
|
|
|
colitems = config.getinitialnodes()
|
2008-08-16 23:26:59 +08:00
|
|
|
assert len(colitems) == 1
|
|
|
|
col = colitems[0]
|
|
|
|
assert isinstance(col, py.test.collect.Directory)
|
|
|
|
for col in col.listchain():
|
2009-03-18 07:48:07 +08:00
|
|
|
assert col.config is config
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2010-01-11 04:29:36 +08:00
|
|
|
def test_twodirs(self, testdir, tmpdir):
|
2009-12-30 01:02:54 +08:00
|
|
|
config = testdir.reparseconfig([tmpdir, tmpdir])
|
2010-01-11 04:29:36 +08:00
|
|
|
colitems = config.getinitialnodes()
|
2008-08-16 23:26:59 +08:00
|
|
|
assert len(colitems) == 2
|
|
|
|
col1, col2 = colitems
|
|
|
|
assert col1.name == col2.name
|
|
|
|
assert col1.parent == col2.parent
|
|
|
|
|
2010-01-11 04:29:36 +08:00
|
|
|
def test_curdir_and_subdir(self, testdir, tmpdir):
|
2009-02-27 18:18:27 +08:00
|
|
|
a = tmpdir.ensure("a", dir=1)
|
2009-12-30 01:02:54 +08:00
|
|
|
config = testdir.reparseconfig([tmpdir, a])
|
2010-01-11 04:29:36 +08:00
|
|
|
colitems = config.getinitialnodes()
|
2008-08-16 23:26:59 +08:00
|
|
|
assert len(colitems) == 2
|
|
|
|
col1, col2 = colitems
|
2009-02-27 18:18:27 +08:00
|
|
|
assert col1.name == tmpdir.basename
|
2008-08-16 23:26:59 +08:00
|
|
|
assert col2.name == 'a'
|
|
|
|
for col in colitems:
|
|
|
|
for subcol in col.listchain():
|
2009-03-18 07:48:07 +08:00
|
|
|
assert col.config is config
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2010-01-11 04:29:36 +08:00
|
|
|
def test_global_file(self, testdir, tmpdir):
|
2009-02-27 18:18:27 +08:00
|
|
|
x = tmpdir.ensure("x.py")
|
2009-12-30 01:02:54 +08:00
|
|
|
config = testdir.reparseconfig([x])
|
2010-01-11 04:29:36 +08:00
|
|
|
col, = config.getinitialnodes()
|
2008-08-16 23:26:59 +08:00
|
|
|
assert isinstance(col, py.test.collect.Module)
|
|
|
|
assert col.name == 'x.py'
|
2009-02-27 18:18:27 +08:00
|
|
|
assert col.parent.name == tmpdir.basename
|
2010-01-03 08:02:44 +08:00
|
|
|
assert isinstance(col.parent.parent, RootCollector)
|
2008-08-16 23:26:59 +08:00
|
|
|
for col in col.listchain():
|
2009-03-18 07:48:07 +08:00
|
|
|
assert col.config is config
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2010-01-11 04:29:36 +08:00
|
|
|
def test_global_dir(self, testdir, tmpdir):
|
2009-02-27 18:18:27 +08:00
|
|
|
x = tmpdir.ensure("a", dir=1)
|
2009-12-30 01:02:54 +08:00
|
|
|
config = testdir.reparseconfig([x])
|
2010-01-11 04:29:36 +08:00
|
|
|
col, = config.getinitialnodes()
|
2008-08-16 23:26:59 +08:00
|
|
|
assert isinstance(col, py.test.collect.Directory)
|
2009-08-30 02:04:48 +08:00
|
|
|
print(col.listchain())
|
2008-08-16 23:26:59 +08:00
|
|
|
assert col.name == 'a'
|
2010-01-03 08:02:44 +08:00
|
|
|
assert isinstance(col.parent, RootCollector)
|
2009-03-18 07:48:07 +08:00
|
|
|
assert col.config is config
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2010-01-11 04:29:36 +08:00
|
|
|
def test_pkgfile(self, testdir, tmpdir):
|
2010-04-27 21:49:13 +08:00
|
|
|
tmpdir = tmpdir.join("subdir")
|
2009-02-27 18:18:27 +08:00
|
|
|
x = tmpdir.ensure("x.py")
|
|
|
|
tmpdir.ensure("__init__.py")
|
2009-12-30 01:02:54 +08:00
|
|
|
config = testdir.reparseconfig([x])
|
2010-01-11 04:29:36 +08:00
|
|
|
col, = config.getinitialnodes()
|
2008-08-16 23:26:59 +08:00
|
|
|
assert isinstance(col, py.test.collect.Module)
|
|
|
|
assert col.name == 'x.py'
|
|
|
|
assert col.parent.name == x.dirpath().basename
|
2010-01-03 08:02:44 +08:00
|
|
|
assert isinstance(col.parent.parent.parent, RootCollector)
|
2008-08-16 23:26:59 +08:00
|
|
|
for col in col.listchain():
|
2009-03-18 07:48:07 +08:00
|
|
|
assert col.config is config
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-02-27 18:18:27 +08:00
|
|
|
class TestConfig_gettopdir:
|
|
|
|
def test_gettopdir(self, testdir):
|
2010-01-14 00:15:54 +08:00
|
|
|
from py._test.config import gettopdir
|
2009-02-27 18:18:27 +08:00
|
|
|
tmp = testdir.tmpdir
|
|
|
|
assert gettopdir([tmp]) == tmp
|
|
|
|
topdir = gettopdir([tmp.join("hello"), tmp.join("world")])
|
|
|
|
assert topdir == tmp
|
|
|
|
somefile = tmp.ensure("somefile.py")
|
|
|
|
assert gettopdir([somefile]) == tmp
|
|
|
|
|
|
|
|
def test_gettopdir_pypkg(self, testdir):
|
2010-01-14 00:15:54 +08:00
|
|
|
from py._test.config import gettopdir
|
2009-02-27 18:18:27 +08:00
|
|
|
tmp = testdir.tmpdir
|
|
|
|
a = tmp.ensure('a', dir=1)
|
|
|
|
b = tmp.ensure('a', 'b', '__init__.py')
|
|
|
|
c = tmp.ensure('a', 'b', 'c.py')
|
|
|
|
Z = tmp.ensure('Z', dir=1)
|
|
|
|
assert gettopdir([c]) == a
|
|
|
|
assert gettopdir([c, Z]) == tmp
|
2010-01-11 04:29:36 +08:00
|
|
|
assert gettopdir(["%s::xyc" % c]) == a
|
|
|
|
assert gettopdir(["%s::xyc::abc" % c]) == a
|
|
|
|
assert gettopdir(["%s::xyc" % c, "%s::abc" % Z]) == tmp
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-02-28 05:32:49 +08:00
|
|
|
def test_options_on_small_file_do_not_blow_up(testdir):
|
|
|
|
def runfiletest(opts):
|
2009-05-21 20:33:09 +08:00
|
|
|
reprec = testdir.inline_run(*opts)
|
|
|
|
passed, skipped, failed = reprec.countoutcomes()
|
2009-02-28 05:32:49 +08:00
|
|
|
assert failed == 2
|
|
|
|
assert skipped == passed == 0
|
|
|
|
path = testdir.makepyfile("""
|
|
|
|
def test_f1(): assert 0
|
|
|
|
def test_f2(): assert 0
|
|
|
|
""")
|
|
|
|
|
|
|
|
for opts in ([], ['-l'], ['-s'], ['--tb=no'], ['--tb=short'],
|
|
|
|
['--tb=long'], ['--fulltrace'], ['--nomagic'],
|
|
|
|
['--traceconfig'], ['-v'], ['-v', '-v']):
|
|
|
|
runfiletest(opts + [path])
|
2009-02-27 18:18:27 +08:00
|
|
|
|
2009-12-30 05:26:03 +08:00
|
|
|
def test_ensuretemp(recwarn):
|
|
|
|
#py.test.deprecated_call(py.test.ensuretemp, 'hello')
|
2009-03-17 20:42:40 +08:00
|
|
|
d1 = py.test.ensuretemp('hello')
|
|
|
|
d2 = py.test.ensuretemp('hello')
|
|
|
|
assert d1 == d2
|
|
|
|
assert d1.check(dir=1)
|
2010-01-03 00:17:13 +08:00
|
|
|
|
|
|
|
def test_preparse_ordering(testdir, monkeypatch):
|
|
|
|
pkg_resources = py.test.importorskip("pkg_resources")
|
|
|
|
def my_iter(name):
|
|
|
|
assert name == "pytest11"
|
|
|
|
class EntryPoint:
|
|
|
|
name = "mytestplugin"
|
|
|
|
def load(self):
|
|
|
|
class PseudoPlugin:
|
|
|
|
x = 42
|
|
|
|
return PseudoPlugin()
|
|
|
|
return iter([EntryPoint()])
|
|
|
|
monkeypatch.setattr(pkg_resources, 'iter_entry_points', my_iter)
|
|
|
|
testdir.makeconftest("""
|
|
|
|
pytest_plugins = "mytestplugin",
|
|
|
|
""")
|
|
|
|
monkeypatch.setenv("PYTEST_PLUGINS", "mytestplugin")
|
|
|
|
config = testdir.parseconfig()
|
|
|
|
plugin = config.pluginmanager.getplugin("mytestplugin")
|
|
|
|
assert plugin.x == 42
|
|
|
|
|
2010-01-18 06:23:02 +08:00
|
|
|
|
|
|
|
import pickle
|
|
|
|
class TestConfigPickling:
|
|
|
|
def pytest_funcarg__testdir(self, request):
|
|
|
|
oldconfig = py.test.config
|
|
|
|
print("setting py.test.config to None")
|
|
|
|
py.test.config = None
|
|
|
|
def resetglobals():
|
|
|
|
py.builtin.print_("setting py.test.config to", oldconfig)
|
|
|
|
py.test.config = oldconfig
|
|
|
|
request.addfinalizer(resetglobals)
|
|
|
|
return request.getfuncargvalue("testdir")
|
|
|
|
|
|
|
|
def test_config_getstate_setstate(self, testdir):
|
|
|
|
from py._test.config import Config
|
|
|
|
testdir.makepyfile(__init__="", conftest="x=1; y=2")
|
|
|
|
hello = testdir.makepyfile(hello="")
|
|
|
|
tmp = testdir.tmpdir
|
|
|
|
testdir.chdir()
|
|
|
|
config1 = testdir.parseconfig(hello)
|
|
|
|
config2 = Config()
|
|
|
|
config2.__setstate__(config1.__getstate__())
|
|
|
|
assert config2.topdir == py.path.local()
|
|
|
|
config2_relpaths = [py.path.local(x).relto(config2.topdir)
|
|
|
|
for x in config2.args]
|
|
|
|
config1_relpaths = [py.path.local(x).relto(config1.topdir)
|
|
|
|
for x in config1.args]
|
|
|
|
|
|
|
|
assert config2_relpaths == config1_relpaths
|
|
|
|
for name, value in config1.option.__dict__.items():
|
|
|
|
assert getattr(config2.option, name) == value
|
|
|
|
assert config2.getvalue("x") == 1
|
|
|
|
|
|
|
|
def test_config_pickling_customoption(self, testdir):
|
|
|
|
testdir.makeconftest("""
|
|
|
|
def pytest_addoption(parser):
|
|
|
|
group = parser.getgroup("testing group")
|
|
|
|
group.addoption('-G', '--glong', action="store", default=42,
|
|
|
|
type="int", dest="gdest", help="g value.")
|
|
|
|
""")
|
|
|
|
config = testdir.parseconfig("-G", "11")
|
|
|
|
assert config.option.gdest == 11
|
|
|
|
repr = config.__getstate__()
|
|
|
|
|
|
|
|
config = testdir.Config()
|
|
|
|
py.test.raises(AttributeError, "config.option.gdest")
|
|
|
|
|
|
|
|
config2 = testdir.Config()
|
|
|
|
config2.__setstate__(repr)
|
|
|
|
assert config2.option.gdest == 11
|
|
|
|
|
|
|
|
def test_config_pickling_and_conftest_deprecated(self, testdir):
|
|
|
|
tmp = testdir.tmpdir.ensure("w1", "w2", dir=1)
|
|
|
|
tmp.ensure("__init__.py")
|
|
|
|
tmp.join("conftest.py").write(py.code.Source("""
|
|
|
|
def pytest_addoption(parser):
|
|
|
|
group = parser.getgroup("testing group")
|
|
|
|
group.addoption('-G', '--glong', action="store", default=42,
|
|
|
|
type="int", dest="gdest", help="g value.")
|
|
|
|
"""))
|
|
|
|
config = testdir.parseconfig(tmp, "-G", "11")
|
|
|
|
assert config.option.gdest == 11
|
|
|
|
repr = config.__getstate__()
|
|
|
|
|
|
|
|
config = testdir.Config()
|
|
|
|
py.test.raises(AttributeError, "config.option.gdest")
|
|
|
|
|
|
|
|
config2 = testdir.Config()
|
|
|
|
config2.__setstate__(repr)
|
|
|
|
assert config2.option.gdest == 11
|
|
|
|
|
|
|
|
option = config2.addoptions("testing group",
|
|
|
|
config2.Option('-G', '--glong', action="store", default=42,
|
|
|
|
type="int", dest="gdest", help="g value."))
|
|
|
|
assert option.gdest == 11
|
|
|
|
|
|
|
|
def test_config_picklability(self, testdir):
|
|
|
|
config = testdir.parseconfig()
|
|
|
|
s = pickle.dumps(config)
|
|
|
|
newconfig = pickle.loads(s)
|
|
|
|
assert hasattr(newconfig, "topdir")
|
|
|
|
assert newconfig.topdir == py.path.local()
|
|
|
|
|
|
|
|
def test_collector_implicit_config_pickling(self, testdir):
|
|
|
|
tmpdir = testdir.tmpdir
|
|
|
|
testdir.chdir()
|
|
|
|
testdir.makepyfile(hello="def test_x(): pass")
|
|
|
|
config = testdir.parseconfig(tmpdir)
|
|
|
|
col = config.getnode(config.topdir)
|
|
|
|
io = py.io.BytesIO()
|
|
|
|
pickler = pickle.Pickler(io)
|
|
|
|
pickler.dump(col)
|
|
|
|
io.seek(0)
|
|
|
|
unpickler = pickle.Unpickler(io)
|
|
|
|
col2 = unpickler.load()
|
|
|
|
assert col2.name == col.name
|
|
|
|
assert col2.listnames() == col.listnames()
|
|
|
|
|
|
|
|
def test_config_and_collector_pickling(self, testdir):
|
|
|
|
tmpdir = testdir.tmpdir
|
|
|
|
dir1 = tmpdir.ensure("sourcedir", "somedir", dir=1)
|
|
|
|
config = testdir.parseconfig()
|
|
|
|
assert config.topdir == tmpdir
|
|
|
|
col = config.getnode(dir1.dirpath())
|
|
|
|
col1 = config.getnode(dir1)
|
|
|
|
assert col1.parent == col
|
|
|
|
io = py.io.BytesIO()
|
|
|
|
pickler = pickle.Pickler(io)
|
|
|
|
pickler.dump(col)
|
|
|
|
pickler.dump(col1)
|
|
|
|
pickler.dump(col)
|
|
|
|
io.seek(0)
|
|
|
|
unpickler = pickle.Unpickler(io)
|
|
|
|
newtopdir = tmpdir.ensure("newtopdir", dir=1)
|
|
|
|
newtopdir.mkdir("sourcedir").mkdir("somedir")
|
|
|
|
old = newtopdir.chdir()
|
|
|
|
try:
|
|
|
|
newcol = unpickler.load()
|
|
|
|
newcol2 = unpickler.load()
|
|
|
|
newcol3 = unpickler.load()
|
|
|
|
assert newcol2.config is newcol.config
|
|
|
|
assert newcol2.parent == newcol
|
|
|
|
assert newcol2.config.topdir.realpath() == newtopdir.realpath()
|
|
|
|
newsourcedir = newtopdir.join("sourcedir")
|
|
|
|
assert newcol.fspath.realpath() == newsourcedir.realpath()
|
|
|
|
assert newcol2.fspath.basename == dir1.basename
|
|
|
|
assert newcol2.fspath.relto(newcol2.config.topdir)
|
|
|
|
finally:
|
|
|
|
old.chdir()
|