Exemplo n.º 1
0
def test_html_module_index():
    with tutils.tdir():
        roots = [
            pdoc.extract.extract_module("./modules/one"),
            pdoc.extract.extract_module("./modules/submods")
        ]
        assert pdoc.render.html_index(roots)
Exemplo n.º 2
0
def test_static(tmpdir):
    dst = pathlib.Path(str(tmpdir))
    with tutils.tdir():
        one = pdocs.extract.extract_module("./modules/one")
        two = pdocs.extract.extract_module("./modules/submods")
        assert not pdocs.static.would_overwrite(dst, [one])
        assert not pdocs.static.would_overwrite(dst, [one, two])
Exemplo n.º 3
0
def test_extract_module(path, expected, match):
    with tutils.tdir():
        if match:
            with pytest.raises(pdoc.extract.ExtractError, match=match):
                pdoc.extract.extract_module(path)
        else:
            ret = pdoc.extract.extract_module(path)
            assert sorted([i.name for i in ret.allmodules()]) == expected
Exemplo n.º 4
0
def test_load_module(path, mod, expected, match):
    with tutils.tdir():
        if match:
            with pytest.raises(pdocs.extract.ExtractError, match=match):
                pdocs.extract.load_module(path, mod)
        else:
            _, ispkg = pdocs.extract.load_module(path, mod)
            assert ispkg == expected
Exemplo n.º 5
0
def test_extract_module(path, expected, match):
    with tutils.tdir():
        if match:
            with pytest.raises(pdocs.extract.ExtractError, match=match):
                pdocs.extract.extract_module(path)
        else:
            ret = pdocs.extract.extract_module(path)
            assert sorted([i.name for i in ret.allmodules()]) == expected
Exemplo n.º 6
0
def test_load_module(path, mod, expected, match):
    with tutils.tdir():
        if match:
            with pytest.raises(pdoc.extract.ExtractError, match=match):
                pdoc.extract.load_module(path, mod)
        else:
            _, ispkg = pdoc.extract.load_module(path, mod)
            assert ispkg == expected
Exemplo n.º 7
0
def test_static(tmpdir):
    dst = pathlib.Path(str(tmpdir))
    with tutils.tdir():
        one = pdoc.extract.extract_module("./modules/one")
        two = pdoc.extract.extract_module("./modules/submods")
        assert not pdoc.static.would_overwrite(dst, [one])
        assert not pdoc.static.would_overwrite(dst, [one, two])
        pdoc.static.html_out(dst, [one])
        assert pdoc.static.would_overwrite(dst, [one])
        assert pdoc.static.would_overwrite(dst, [one, two])
        pdoc.static.html_out(dst, [one, two])
        assert pdoc.static.would_overwrite(dst, [one])
        assert pdoc.static.would_overwrite(dst, [one, two])
Exemplo n.º 8
0
def test_module_path(modspec, ident, path):
    with tutils.tdir():
        root = pdoc.extract.extract_module(modspec)
        submod = root.find_ident(ident)

        mp = pdoc.static.module_to_path(submod)
        assert mp == pathlib.Path(path)

        retmod = pdoc.static.path_to_module([root], mp)
        assert retmod.name == submod.name

        retmod = pdoc.static.path_to_module([root], mp.with_suffix(""))
        assert retmod.name == submod.name
Exemplo n.º 9
0
def test_module_path(modspec, ident, path):
    with tutils.tdir():
        root = pdoc.extract.extract_module(modspec)
        submod = root.find_ident(ident)

        mp = pdoc.static.module_to_path(submod)
        assert mp == pathlib.Path(path)

        retmod = pdoc.static.path_to_module([root], mp)
        assert retmod.name == submod.name

        retmod = pdoc.static.path_to_module([root], mp.with_suffix(""))
        assert retmod.name == submod.name
Exemplo n.º 10
0
def test_extract_module():
    with tutils.tdir():
        with pytest.raises(pdoc.extract.ExtractError, match="not found"):
            pdoc.extract.extract_module("./modules/nonexistent.py")
        with pytest.raises(pdoc.extract.ExtractError, match="not found"):
            pdoc.extract.extract_module("./modules/nonexistent/foo")
        with pytest.raises(pdoc.extract.ExtractError,
                           match="Invalid module name"):
            pdoc.extract.extract_module("./modules/one.two")
        with pytest.raises(pdoc.extract.ExtractError,
                           match="Module not found"):
            pdoc.extract.extract_module("nonexistent.module")
        with pytest.raises(pdoc.extract.ExtractError, match="Error importing"):
            pdoc.extract.extract_module("./modules/malformed/syntax.py")
        with pytest.raises(pdoc.extract.ExtractError, match="Error importing"):
            pdoc.extract.extract_module("packages/malformed_syntax")

        assert pdoc.extract.extract_module("./modules/one.py")
        assert pdoc.extract.extract_module("./modules/one")
        assert pdoc.extract.extract_module("./modules/dirmod")
        assert pdoc.extract.extract_module("./modules/submods")
        assert pdoc.extract.extract_module("csv")
        assert pdoc.extract.extract_module("html.parser")
        assert pdoc.extract.extract_module("packages.simple")
Exemplo n.º 11
0
def test_html_module():
    with tutils.tdir():
        m = pdoc.extract.extract_module("./modules/one")
        assert pdoc.render.html_module(m)
Exemplo n.º 12
0
def test_submodules(path, modname, expected):
    with tutils.tdir():
        ret = pdoc.extract.submodules(path, modname)
        assert ret == expected
Exemplo n.º 13
0
def test_submodules(path, modname, expected):
    with tutils.tdir():
        ret = pdocs.extract.submodules(path, modname)
        assert ret == expected
Exemplo n.º 14
0
def test_html_module_index():
    with tutils.tdir():
        assert pdoc.render.html_index(modules=[
            ("name", "desc"),
            ("name2", "desc2"),
        ])
Exemplo n.º 15
0
def test_simple():
    with tutils.tdir():
        m = pdoc.extract.extract_module("./modules/one.py")
        assert m
Exemplo n.º 16
0
def test_static_single(tmpdir):
    with tutils.tdir():
        m = pdoc.extract.extract_module("./modules/one")
        pdoc.static.html_out(tmpdir, m)
Exemplo n.º 17
0
def test_path_to_module():
    with tutils.tdir():
        root = pdoc.extract.extract_module("./modules/submods")
        with pytest.raises(pdoc.static.StaticError):
            pdoc.static.path_to_module([root], pathlib.Path("nonexistent"))
Exemplo n.º 18
0
def init_dirs(config):
    for dirname in config['basic_dirs']:
        tdir(dirname)
        # Make __init__.py for each dir
        make_file(tfilename(dirname, '__init__.py'))
Exemplo n.º 19
0
def test_simple():
    with tutils.tdir():
        m = pdoc.extract.extract_module("./modules/one.py")
        assert (m)
Exemplo n.º 20
0
def test_path_to_module():
    with tutils.tdir():
        root = pdoc.extract.extract_module("./modules/submods")
        with pytest.raises(pdoc.static.StaticError):
            pdoc.static.path_to_module([root], pathlib.Path("nonexistent"))