Coverage for tests / test_completion / test_completion_choice.py: 100%

13 statements  

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

1import os 1abcdefghij

2import subprocess 1abcdefghij

3import sys 1abcdefghij

4 

5from . import choice_example as mod 1abcdefghij

6 

7 

8def test_script() -> None: 1abcdefghij

9 result = subprocess.run( 1abcdefghij

10 [sys.executable, "-m", "coverage", "run", mod.__file__, "--name", "rick"], 

11 capture_output=True, 

12 encoding="utf-8", 

13 ) 

14 assert result.returncode == 0 1abcdefghij

15 assert "rick" in result.stdout 1abcdefghij

16 

17 

18def test_completion_choice_bash() -> None: 1abcdefghij

19 result = subprocess.run( 1abcdefghij

20 [sys.executable, "-m", "coverage", "run", mod.__file__, " "], 

21 capture_output=True, 

22 encoding="utf-8", 

23 env={ 

24 **os.environ, 

25 "_CHOICE_EXAMPLE.PY_COMPLETE": "complete_bash", 

26 "COMP_WORDS": "choice_example.py --name mo", 

27 "COMP_CWORD": "2", 

28 }, 

29 ) 

30 assert result.returncode == 0 1abcdefghij

31 assert "morty" in result.stdout 1abcdefghij

32 assert "rick" not in result.stdout 1abcdefghij