Debian Codegraph @

docs/tests/test_standard_library_docs.py

raw
1 #
2 # Run tests after Python standard library's documentation is executed.
3 #
4 # These tests are designed to be executed inside tox, after pydoctor is run.
5 # Alternatively this can be excuted manually from the project root folder like:
6 # pytest docs/tests/test_standard_library_docs.py
7
8 from . import get_toxworkdir_subdir
9
10 PYTHON_DIR = get_toxworkdir_subdir('cpython')
11 BASE_DIR = get_toxworkdir_subdir('cpython-output')
12
13 def test_std_lib_docs() -> None:
14 """
15 For each top-level module in python standard library, check if there is an associated documentation page.
16 """
17 for entry in PYTHON_DIR.joinpath('Lib').iterdir():
18 if entry.is_file() and entry.suffix=='.py': # Module
19 name = entry.name[0:-3]
20 if name == "__init__": continue
21 assert BASE_DIR.joinpath('Lib.'+name+'.html').exists()
22
23 elif entry.is_dir() and entry.joinpath('__init__.py').exists(): # Package
24 assert BASE_DIR.joinpath('Lib.'+entry.name+'.html').exists()
25
26 def test_std_lib_logs() -> None:
27 """
28 'Cannot parse file' do not appear too much.
29 This test expect a run.log file in cpython-output directory
30 """
31 log = (BASE_DIR / 'run.log').read_text()
32 assert log.count('cannot parse file') == 4
33