Coverage for tests / test_rich_import.py: 100%
10 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
1import subprocess 1abcdefgh
2import sys 1abcdefgh
3from pathlib import Path 1abcdefgh
5ACCEPTED_MODULES = {"rich._extension", "rich"} 1abcdefgh
8def test_rich_not_imported_unnecessary(): 1abcdefgh
9 file_path = Path(__file__).parent / "assets/print_modules.py" 1abcdefgh
10 result = subprocess.run( 1abcdefgh
11 [sys.executable, "-m", "coverage", "run", str(file_path)],
12 capture_output=True,
13 encoding="utf-8",
14 )
15 modules = result.stdout.splitlines() 1abcdefgh
16 modules = [ 1abcdefgh
17 module
18 for module in modules
19 if module not in ACCEPTED_MODULES and module.startswith("rich")
20 ]
21 assert not modules 1abcdefgh