Coverage for tests/test_rich_import.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-19 20:29 +0000

1import subprocess 1abcdefghi

2import sys 1abcdefghi

3from pathlib import Path 1abcdefghi

4 

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

6 

7 

8def test_rich_not_imported_unnecessary(): 1abcdefghi

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

10 result = subprocess.run( 1abcdefghi

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

12 capture_output=True, 

13 encoding="utf-8", 

14 ) 

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

16 modules = [ 1abcdefghi

17 module 

18 for module in modules 

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

20 ] 

21 assert not modules 1abcdefghi