Ejemplo n.º 1
0
def test_load_suites_from_directory_with_subdir(tmpdir):
    file = tmpdir.join("parentsuite.py")
    file.write(build_test_module("parentsuite"))
    subdir = tmpdir.join("parentsuite")
    subdir.mkdir()
    file = subdir.join("childsuite.py")
    file.write(build_test_module("childsuite"))
    klasses = load_suites_from_directory(tmpdir.strpath)
    assert klasses[0].name == "parentsuite"
    assert len(klasses[0].get_suites()) == 1
Ejemplo n.º 2
0
def test_load_suites_from_files_exclude(tmpdir):
    for name in "suite1", "suite2", "mysuite":
        tmpdir.join(name + ".py").write(build_test_module(name))
    klasses = load_suites_from_files(
        tmpdir.join("*.py").strpath, "*/suite*.py")
    assert len(klasses) == 1
    assert klasses[0].name == "mysuite"
Ejemplo n.º 3
0
def test_load_suites_from_files(tmpdir):
    for name in "suite1", "suite2", "mysuite":
        tmpdir.join(name + ".py").write(build_test_module(name))
    klasses = load_suites_from_files(tmpdir.join("suite*.py").strpath)
    assert len(klasses) == 2
    assert "suite1" in [k.name for k in klasses]
    assert "suite2" in [k.name for k in klasses]
Ejemplo n.º 4
0
def test_load_suites_from_directory_with_modules(tmpdir):
    names = []
    for i in range(3):
        name = "mysuite%d" % i
        names.append(name)
        tmpdir.join("%s.py" % name).write(build_test_module(name))
    klasses = load_suites_from_directory(tmpdir.strpath)
    for name in names:
        assert name in [k.name for k in klasses]
Ejemplo n.º 5
0
def test_get_suites(tmpdir):
    file = tmpdir.join("mysuite.py")
    file.write(build_test_module())
    project = make_test_project(tmpdir)
    suites = project.get_suites()
    assert len(suites) == 1 and suites[0].name == "mysuite"
Ejemplo n.º 6
0
def test_get_project_dir(tmpdir):
    file = tmpdir.join("mysuite.py")
    file.write(build_test_module())
    project = make_test_project(tmpdir)
    assert project.get_project_dir() == tmpdir
Ejemplo n.º 7
0
def test_load_suite_from_file_invalid_class(tmpdir):
    file = tmpdir.join("anothersuite.py")
    file.write(build_test_module())
    with pytest.raises(ModuleImportError):
        load_suite_from_file(file.strpath)
Ejemplo n.º 8
0
def test_load_suite_from_file(tmpdir):
    file = tmpdir.join("mysuite.py")
    file.write(build_test_module())
    klass = load_suite_from_file(file.strpath)
    assert klass.name == "mysuite"