pyan icon indicating copy to clipboard operation
pyan copied to clipboard

Improve test coverage

Open Technologicat opened this issue 2 months ago • 0 comments

The unit tests of Pyan are very incomplete and do not cover much of the analyzer. This should be improved.

What we need is mainly example code for the analyzer to analyze, and invocations to do so in tests/.

Here's a test report by @amw007, from discussion of #104:

Tests with 3.11

uv run python -m pytest tests -q
============================================================================ test session starts =============================================================================
platform linux -- Python 3.11.4, pytest-8.4.2, pluggy-1.6.0 -- pyan/.venv/bin/python3
cachedir: .cache
rootdir: pyan
configfile: pytest.ini
plugins: cov-7.0.0
collected 6 items                                                                                                                                                            

tests/test_analyzer.py::test_resolve_import_as PASSED                                                                                                                  [ 16%]
tests/test_analyzer.py::test_import_relative PASSED                                                                                                                    [ 33%]
tests/test_analyzer.py::test_resolve_use_in_class PASSED                                                                                                               [ 50%]
tests/test_analyzer.py::test_resolve_use_in_function PASSED                                                                                                            [ 66%]
tests/test_analyzer.py::test_resolve_package_without___init__ PASSED                                                                                                   [ 83%]
tests/test_analyzer.py::test_resolve_package_with_known_root PASSED                                                                                                    [100%]

=============================================================================== tests coverage ===============================================================================
coverage: platform linux, python  #3.11.4-final-0

Name             Stmts   Miss  Cover   Missing

pyan/__init__.py      46     33    28%   11-20, 77-119

pyan/__main__.py       3      3     0%   3-6

pyan/analyzer.py     776    263    66%   100, 125-137, 188, 194, 206, 222-225, 255-268, 286-330, 384-386, 466, 470-475, 498, 500, 502, 512-516, 518-523, 611, 649-652, 657-660, 738, 752, 773-789, 794-809, 819-828, 831, 834-835, 838-839, 842-843, 846-847, 859-885, 894, 899-900, 903-909, 929-934, 939-979, 995, 1001-1005, 1013, 1015, 1082-1086, 1106, 1112-1138, 1141-1153, 1170, 1185-1190, 1204-1219, 1275, 1320-1324, 1342-1344, 1365, 1367, 1381, 1399-1406, 1419, 1421, 1424, 1434, 1468, 1501-1505, 1601, 1604, 1650, 1655-1657, 1691-1693, 1696-1697, 1703-1705, 1708-1709, 1714, 1733-1738, 1741-1742, 1745, 1758-1764

pyan/anutils.py      162     79    51%   13-14, 18-21, 43, 63, 93, 114-122, 125, 128, 131-143, 157-166, 174-200, 244-245, 252-263, 267-287

pyan/main.py          81     72    11%   23-243, 247
pyan/node.py          82     33    60%   11-15, 103-106, 111-117, 122-137, 156-159, 163-172, 179, 186

pyan/sphinx.py        64     64     0%   27-167

pyan/visgraph.py     149    128    14%   23-28, 31-36, 39-43, 46-47, 50-63, 67-72, 81-86, 89-93, 104-107, 110, 115-120, 124-251

pyan/writers.py      233    185    21%   17-21, 24, 27, 30, 33, 36-49, 52-57, 60-63, 66, 69, 72, 75, 78, 81, 84, 87, 92-94, 97-99, 102, 105-106, 111-116, 119-121, 124-131, 134-137, 140-141, 147-153, 156, 162-181, 186-206, 211-214, 217-236, 239-265, 268-272, 275-293, 296-316, 319-322

TOTAL               1596    860    46%
Coverage HTML written to dir htmlcov
============================================================================= 6 passed in 10.28s =============================================================================

Technologicat avatar Nov 07 '25 06:11 Technologicat