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)
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])
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
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
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
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
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])
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
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")
def test_html_module(): with tutils.tdir(): m = pdoc.extract.extract_module("./modules/one") assert pdoc.render.html_module(m)
def test_submodules(path, modname, expected): with tutils.tdir(): ret = pdoc.extract.submodules(path, modname) assert ret == expected
def test_submodules(path, modname, expected): with tutils.tdir(): ret = pdocs.extract.submodules(path, modname) assert ret == expected
def test_html_module_index(): with tutils.tdir(): assert pdoc.render.html_index(modules=[ ("name", "desc"), ("name2", "desc2"), ])
def test_simple(): with tutils.tdir(): m = pdoc.extract.extract_module("./modules/one.py") assert m
def test_static_single(tmpdir): with tutils.tdir(): m = pdoc.extract.extract_module("./modules/one") pdoc.static.html_out(tmpdir, m)
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"))
def init_dirs(config): for dirname in config['basic_dirs']: tdir(dirname) # Make __init__.py for each dir make_file(tfilename(dirname, '__init__.py'))
def test_simple(): with tutils.tdir(): m = pdoc.extract.extract_module("./modules/one.py") assert (m)