Coverage for tests/test_main.py: 100%

1 import random

2 from typoglycemia.main import shuffle, make_typoglycemia

3 import subprocess

4 import sys

5 import pytest

6@pytest.fixture(autouse=True)

7 def 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])

15 def 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])

23 def test_make_typoglycemia(input_sentence, expected_output):

24 assert make_typoglycemia(input_sentence) == expected_output

25

26 def 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