Coverage for tests/test_main.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-22 16:36 +0900

1import random 

2from typoglycemia.main import shuffle, make_typoglycemia 

3import subprocess 

4import sys 

5import pytest 

6@pytest.fixture(autouse=True) 

7def set_seed(): 

8 random.seed(100) 

9 

10@pytest.mark.parametrize("input_word, expected_output", [ 

11 ("hello", "hello"), 

12 ("hi", "hi"), 

13 ("__init__.py", "__init__.py") 

14]) 

15def test_shuffle(input_word, expected_output): 

16 assert shuffle(input_word) == expected_output 

17 

18@pytest.mark.parametrize("input_sentence, expected_output", [ 

19 ("hello world", "hello world"), 

20 ("hi world", "hi world"), 

21 ("__init__.py", "__init__.py") 

22]) 

23def test_make_typoglycemia(input_sentence, expected_output): 

24 assert make_typoglycemia(input_sentence) == expected_output 

25 

26def test_cli(): 

27 args = [sys.executable, "-m", "typoglycemia", "-t", "test"] 

28 process = subprocess.run(args, capture_output=True, text=True, check=True) 

29 

30 assert process.stdout