Exemplo n.º 1
0
def test_small_directory_tree():
    datadir = DATA_DIR
    paths = (('a', '__init__.py'), ('a', 'b.py'), ('a', 'py.py'),
             ('a', 'c', '__init__.py'), ('a', 'c', 'd.py'))
    expected = sorted(datadir / Path(*path) for path in paths)
    with extend_path(datadir):
        results = sorted(Path(m.__file__) for m in find_modules('a'))
    assert expected == results
Exemplo n.º 2
0
def test_finding_modules_via_dir_name_and_filename_ending_in_py():
    datadir = DATA_DIR
    paths = (('a', 'c', 'd.py'), )
    expected = sorted(datadir / Path(*path) for path in paths)
    with extend_path(datadir), excursion(datadir):
        module_name = fixup_module_name('a/c/d.py')
        results = sorted(Path(m.__file__) for m in find_modules(module_name))
    assert expected == results
Exemplo n.º 3
0
def test_finding_modules_py_dot_py_using_slashes_with_full_filename():
    datadir = DATA_DIR
    paths = (('a', 'py.py'), )
    expected = sorted(datadir / Path(*path) for path in paths)
    with extend_path(datadir), excursion(datadir):
        module_name = fixup_module_name('a/py.py')
        results = sorted(Path(m.__file__) for m in find_modules(module_name))
    # a/py.py is a module and it is loaded
    assert expected == results
Exemplo n.º 4
0
def test_finding_module_py_dot_py_using_dots():
    datadir = DATA_DIR
    paths = (('a', 'py.py'), )
    expected = sorted(datadir / Path(*path) for path in paths)
    with extend_path(datadir), excursion(datadir):
        module_name = fixup_module_name('a.py')
        results = sorted(Path(m.__file__) for m in find_modules(module_name))
    # a.py is not a path so we load a/py.py
    assert expected == results
Exemplo n.º 5
0
def test_no_test_return_value():
    with extend_path(DATA_DIR), excursion(DATA_DIR):
        test_runner = get_test_runner("unittest", ".")
        result = worker("a.b", zero_iteration_loop.ZeroIterationLoop, 100,
                        test_runner)
        expected = WorkItem(data=None,
                            test_outcome=None,
                            worker_outcome=WorkerOutcome.NO_TEST,
                            diff=None,
                            module=None,
                            operator=None,
                            occurrence=None,
                            line_number=None,
                            command_line=None,
                            job_id=None)

        assert result == expected
Exemplo n.º 6
0
def test_finding_modules_py_dot_py_using_slashes():
    datadir = DATA_DIR
    with extend_path(datadir):
        results = sorted(Path(m.__file__) for m in find_modules('a/py'))
    # a/py isn't a directory so nothing is loaded
    assert [] == results