當前位置: 首頁>>代碼示例>>Python>>正文


Python Conftest.setinitial方法代碼示例

本文整理匯總了Python中_pytest.config.Conftest.setinitial方法的典型用法代碼示例。如果您正苦於以下問題:Python Conftest.setinitial方法的具體用法?Python Conftest.setinitial怎麽用?Python Conftest.setinitial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在_pytest.config.Conftest的用法示例。


在下文中一共展示了Conftest.setinitial方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_conftestcutdir_inplace_considered

# 需要導入模塊: from _pytest.config import Conftest [as 別名]
# 或者: from _pytest.config.Conftest import setinitial [as 別名]
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))
開發者ID:burrowsa,項目名稱:pytest,代碼行數:9,代碼來源:test_conftest.py

示例2: test_doubledash_not_considered

# 需要導入模塊: from _pytest.config import Conftest [as 別名]
# 或者: from _pytest.config.Conftest import setinitial [as 別名]
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
開發者ID:burrowsa,項目名稱:pytest,代碼行數:9,代碼來源:test_conftest.py

示例3: test_onimport

# 需要導入模塊: from _pytest.config import Conftest [as 別名]
# 或者: from _pytest.config.Conftest import setinitial [as 別名]
 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
開發者ID:burrowsa,項目名稱:pytest,代碼行數:11,代碼來源:test_conftest.py

示例4: test_issue151_load_all_conftests

# 需要導入模塊: from _pytest.config import Conftest [as 別名]
# 或者: from _pytest.config.Conftest import setinitial [as 別名]
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)
開發者ID:burrowsa,項目名稱:pytest,代碼行數:12,代碼來源:test_conftest.py

示例5: test_setinitial_conftest_subdirs

# 需要導入模塊: from _pytest.config import Conftest [as 別名]
# 或者: from _pytest.config.Conftest import setinitial [as 別名]
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
開發者ID:burrowsa,項目名稱:pytest,代碼行數:13,代碼來源:test_conftest.py

示例6: test_setinitial_confcut

# 需要導入模塊: from _pytest.config import Conftest [as 別名]
# 或者: from _pytest.config.Conftest import setinitial [as 別名]
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()) == []
開發者ID:burrowsa,項目名稱:pytest,代碼行數:17,代碼來源:test_conftest.py

示例7: test_conftestcutdir

# 需要導入模塊: from _pytest.config import Conftest [as 別名]
# 或者: from _pytest.config.Conftest import setinitial [as 別名]
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))
開發者ID:burrowsa,項目名稱:pytest,代碼行數:20,代碼來源:test_conftest.py

示例8: test_basic_init

# 需要導入模塊: from _pytest.config import Conftest [as 別名]
# 或者: from _pytest.config.Conftest import setinitial [as 別名]
 def test_basic_init(self, basedir):
     conftest = Conftest()
     conftest.setinitial([basedir.join("adir")])
     assert conftest.rget("a") == 1
開發者ID:burrowsa,項目名稱:pytest,代碼行數:6,代碼來源:test_conftest.py

示例9: ConftestWithSetinitial

# 需要導入模塊: from _pytest.config import Conftest [as 別名]
# 或者: from _pytest.config.Conftest import setinitial [as 別名]
def ConftestWithSetinitial(path):
    conftest = Conftest()
    conftest.setinitial([path])
    return conftest
開發者ID:burrowsa,項目名稱:pytest,代碼行數:6,代碼來源:test_conftest.py


注:本文中的_pytest.config.Conftest.setinitial方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。