本文整理汇总了Python中_pytest.config.Conftest类的典型用法代码示例。如果您正苦于以下问题:Python Conftest类的具体用法?Python Conftest怎么用?Python Conftest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Conftest类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_conftestcutdir_inplace_considered
def test_conftestcutdir_inplace_considered(testdir):
conf = testdir.makeconftest("")
conftest = Conftest(confcutdir=conf.dirpath())
conftest.setinitial([conf.dirpath()])
l = conftest.getconftestmodules(conf.dirpath())
assert len(l) == 1
assert l[0].__file__.startswith(str(conf))
示例2: test_doubledash_not_considered
def test_doubledash_not_considered(testdir):
conf = testdir.mkdir("--option")
conf.join("conftest.py").ensure()
conftest = Conftest()
conftest.setinitial([conf.basename, conf.basename])
l = conftest.getconftestmodules(None)
assert len(l) == 0
示例3: test_onimport
def test_onimport(self, basedir):
l = []
conftest = Conftest(onimport=l.append)
conftest.setinitial([basedir.join("adir"),
'--confcutdir=%s' % basedir])
assert len(l) == 1
assert conftest.rget("a") == 1
assert conftest.rget("b", basedir.join("adir", "b")) == 2
assert len(l) == 2
示例4: test_onimport
def test_onimport(self, basedir):
l = []
conftest = Conftest(onimport=l.append)
adir = basedir.join("adir")
conftest_setinitial(conftest, [adir], confcutdir=basedir)
assert len(l) == 1
assert conftest.rget_with_confmod("a", adir)[1] == 1
assert conftest.rget_with_confmod("b", adir.join("b"))[1] == 2
assert len(l) == 2
示例5: test_conftest_import_order
def test_conftest_import_order(testdir, monkeypatch):
ct1 = testdir.makeconftest("")
sub = testdir.mkdir("sub")
ct2 = sub.join("conftest.py")
ct2.write("")
def impct(p):
return p
conftest = Conftest()
monkeypatch.setattr(conftest, 'importconftest', impct)
assert conftest.getconftestmodules(sub) == [ct1, ct2]
示例6: test_issue151_load_all_conftests
def test_issue151_load_all_conftests(testdir):
names = "code proj src".split()
for name in names:
p = testdir.mkdir(name)
p.ensure("conftest.py")
conftest = Conftest()
conftest.setinitial(names)
d = list(conftest._conftestpath2mod.values())
assert len(d) == len(names)
示例7: test_setinitial_conftest_subdirs
def test_setinitial_conftest_subdirs(testdir, name):
sub = testdir.mkdir(name)
subconftest = sub.ensure("conftest.py")
conftest = Conftest()
conftest.setinitial([sub.dirpath(), '--confcutdir=%s' % testdir.tmpdir])
if name not in ('whatever', '.dotdir'):
assert subconftest in conftest._conftestpath2mod
assert len(conftest._conftestpath2mod) == 1
else:
assert subconftest not in conftest._conftestpath2mod
assert len(conftest._conftestpath2mod) == 0
示例8: test_setinitial_confcut
def test_setinitial_confcut(testdir):
conf = testdir.makeconftest("")
sub = testdir.mkdir("sub")
sub.chdir()
for opts in (["--confcutdir=%s" % sub, sub],
[sub, "--confcutdir=%s" % sub],
["--confcutdir=.", sub],
[sub, "--confcutdir", sub],
[str(sub), "--confcutdir", "."],
):
conftest = Conftest()
conftest.setinitial(opts)
assert conftest._confcutdir == sub
assert conftest.getconftestmodules(sub) == []
assert conftest.getconftestmodules(conf.dirpath()) == []
示例9: test_immediate_initialiation_and_incremental_are_the_same
def test_immediate_initialiation_and_incremental_are_the_same(self, basedir):
conftest = Conftest()
len(conftest._path2confmods)
conftest.getconftestmodules(basedir)
snap1 = len(conftest._path2confmods)
#assert len(conftest._path2confmods) == snap1 + 1
conftest.getconftestmodules(basedir.join('adir'))
assert len(conftest._path2confmods) == snap1 + 1
conftest.getconftestmodules(basedir.join('b'))
assert len(conftest._path2confmods) == snap1 + 2
示例10: test_conftestcutdir
def test_conftestcutdir(testdir):
conf = testdir.makeconftest("")
p = testdir.mkdir("x")
conftest = Conftest(confcutdir=p)
conftest.setinitial([testdir.tmpdir])
l = conftest.getconftestmodules(p)
assert len(l) == 0
l = conftest.getconftestmodules(conf.dirpath())
assert len(l) == 0
assert conf not in conftest._conftestpath2mod
# but we can still import a conftest directly
conftest.importconftest(conf)
l = conftest.getconftestmodules(conf.dirpath())
assert l[0].__file__.startswith(str(conf))
# and all sub paths get updated properly
l = conftest.getconftestmodules(p)
assert len(l) == 1
assert l[0].__file__.startswith(str(conf))
示例11: test_basic_init
def test_basic_init(self, basedir):
conftest = Conftest()
conftest.setinitial([basedir.join("adir")])
assert conftest.rget("a") == 1
示例12: ConftestWithSetinitial
def ConftestWithSetinitial(path):
conftest = Conftest()
conftest.setinitial([path])
return conftest
示例13: test_basic_init
def test_basic_init(self, basedir):
conftest = Conftest()
p = basedir.join("adir")
assert conftest.rget_with_confmod("a", p)[1] == 1