22# Licensed under the MIT License.
33import os
44import shutil
5+ from typing import Any , Dict , List , Optional
56
67import pytest
78from tests .pytestadapter import expected_execution_test_output
@@ -13,7 +14,7 @@ def test_syntax_error_execution(tmp_path):
1314 """Test pytest execution on a file that has a syntax error.
1415
1516 Copies the contents of a .txt file to a .py file in the temporary directory
16- to then run pytest exeuction on.
17+ to then run pytest execution on.
1718
1819 The json should still be returned but the errors list should be present.
1920
@@ -28,25 +29,29 @@ def test_syntax_error_execution(tmp_path):
2829 temp_dir .mkdir ()
2930 p = temp_dir / "error_syntax_discovery.py"
3031 shutil .copyfile (file_path , p )
31- actual = runner (["error_syntax_discover.py::test_function" ])
32- assert actual
33- assert all (item in actual for item in ("status" , "cwd" , "error" ))
34- assert actual ["status" ] == "error"
35- assert actual ["cwd" ] == os .fspath (TEST_DATA_PATH )
36- assert len (actual ["error" ]) == 1
32+ actual_list : Optional [List [Dict [str , Any ]]] = runner (
33+ ["error_syntax_discover.py::test_function" ]
34+ )
35+ assert actual_list
36+ for actual in actual_list :
37+ assert all (item in actual for item in ("status" , "cwd" , "error" ))
38+ assert actual ["status" ] == "error"
39+ assert actual ["cwd" ] == os .fspath (TEST_DATA_PATH )
40+ assert len (actual ["error" ]) == 1
3741
3842
3943def test_bad_id_error_execution ():
4044 """Test pytest discovery with a non-existent test_id.
4145
4246 The json should still be returned but the errors list should be present.
4347 """
44- actual = runner (["not/a/real::test_id" ])
45- assert actual
46- assert all (item in actual for item in ("status" , "cwd" , "error" ))
47- assert actual ["status" ] == "error"
48- assert actual ["cwd" ] == os .fspath (TEST_DATA_PATH )
49- assert len (actual ["error" ]) == 1
48+ actual_list : Optional [List [Dict [str , Any ]]] = runner (["not/a/real::test_id" ])
49+ assert actual_list
50+ for actual in actual_list :
51+ assert all (item in actual for item in ("status" , "cwd" , "error" ))
52+ assert actual ["status" ] == "error"
53+ assert actual ["cwd" ] == os .fspath (TEST_DATA_PATH )
54+ assert len (actual ["error" ]) == 1
5055
5156
5257@pytest .mark .parametrize (
@@ -153,13 +158,14 @@ def test_pytest_execution(test_ids, expected_const):
153158 expected_const -- a dictionary of the expected output from running pytest discovery on the files.
154159 """
155160 args = test_ids
156- actual = runner (args )
157- assert actual
158- assert all (item in actual for item in ("status" , "cwd" , "result" ))
159- assert actual ["status" ] == "success"
160- assert actual ["cwd" ] == os .fspath (TEST_DATA_PATH )
161- result_data = actual ["result" ]
162- for key in result_data :
163- if result_data [key ]["outcome" ] == "failure" :
164- result_data [key ]["message" ] = "ERROR MESSAGE"
165- assert result_data == expected_const
161+ actual_list : Optional [List [Dict [str , Any ]]] = runner (args )
162+ assert actual_list
163+ for actual in actual_list :
164+ assert all (item in actual for item in ("status" , "cwd" , "result" ))
165+ assert actual ["status" ] == "success"
166+ assert actual ["cwd" ] == os .fspath (TEST_DATA_PATH )
167+ result_data = actual ["result" ]
168+ for key in result_data :
169+ if result_data [key ]["outcome" ] == "failure" :
170+ result_data [key ]["message" ] = "ERROR MESSAGE"
171+ assert result_data == expected_const
0 commit comments