Coverage for tests / test_rich_import.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-11-18 11:12 +0000

1import subprocess 1abcdefghij

2import sys 1abcdefghij

3from pathlib import Path 1abcdefghij

4 

5ACCEPTED_MODULES = {"rich._extension", "rich"} 1abcdefghij

6 

7 

8def test_rich_not_imported_unnecessary(): 1abcdefghij

9 file_path = Path(__file__).parent / "assets/print_modules.py" 1abcdefghij

10 result = subprocess.run( 1abcdefghij

11 [sys.executable, "-m", "coverage", "run", str(file_path)], 

12 capture_output=True, 

13 encoding="utf-8", 

14 ) 

15 modules = result.stdout.splitlines() 1abcdefghij

16 modules = [ 1abcdefghij

17 module 

18 for module in modules 

19 if module not in ACCEPTED_MODULES and module.startswith("rich") 

20 ] 

21 assert not modules 1abcdefghij