Coverage for test/test_invalid_input_files.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.3.0, created at 2023-08-25 16:44 +0200

1"""Test handling of invalid input files""" 

2 

3import pytest 

4 

5import manyworlds as mw 

6 

7 

8def test_invalid_file_mis_spelled_conjunction(): 

9 """Test that the correct error is raised when attempting to parse invalid files""" 

10 with pytest.raises(mw.exceptions.InvalidFeatureFileError) as error_info: 

11 mw.ScenarioForest.from_file( 

12 "test/fixtures/in/invalid/mis-spelled_conjunction.feature" 

13 ) 

14 assert ( 

15 str(error_info.value) 

16 == 'Unable to parse line 2: Whenx I go to "Users" # mis-spelled conjunction' 

17 ) 

18 

19 

20def test_invalid_file_invalid_indentation(): 

21 """Test that the correct error is raised when attempting to parse invalid files""" 

22 with pytest.raises(mw.exceptions.InvalidFeatureFileError) as error_info: 

23 mw.ScenarioForest.from_file( 

24 "test/fixtures/in/invalid/invalid_indentation.feature" 

25 ) 

26 assert ( 

27 str(error_info.value) == "Invalid indentation at line 5: Scenario: " 

28 "Indented using 3 spaces instead of 4" 

29 ) 

30 

31 

32def test_invalid_file_excessive_indentation(): 

33 """Test that the correct error is raised when attempting to parse invalid files""" 

34 with pytest.raises(mw.exceptions.InvalidFeatureFileError) as error_info: 

35 mw.ScenarioForest.from_file( 

36 "test/fixtures/in/invalid/excessive_indentation.feature" 

37 ) 

38 assert ( 

39 str(error_info.value) == "Excessive indentation at line: Scenario: " 

40 "Indented 2 instead of 1 levels" 

41 ) 

42 

43 

44def test_invalid_file_excessive_step_indentation(): 

45 """Test that the correct error is raised when attempting to parse invalid files""" 

46 with pytest.raises(mw.exceptions.InvalidFeatureFileError) as error_info: 

47 mw.ScenarioForest.from_file( 

48 "test/fixtures/in/invalid/excessive_step_indentation.feature" 

49 ) 

50 assert str(error_info.value) == "Invalid indentation at line: " "I see users"