Coverage for tests / test_rich_import.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-03-26 21:46 +0000

1import subprocess 1abcdefg

2import sys 1abcdefg

3from pathlib import Path 1abcdefg

4 

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

6 

7 

8def test_rich_not_imported_unnecessary(): 1abcdefg

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

10 result = subprocess.run( 1abcdefg

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

12 capture_output=True, 

13 encoding="utf-8", 

14 ) 

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

16 modules = [ 1abcdefg

17 module 

18 for module in modules 

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

20 ] 

21 assert not modules 1abcdefg