From e6e1901c4b7c697fe8de98cbd234e67d7b703be0 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Mon, 29 Jan 2024 11:38:30 -0800 Subject: [PATCH 1/2] changes to support pytest 8 --- .../expected_discovery_test_output.py | 84 +++++++++---------- .../tests/pytestadapter/test_discovery.py | 3 +- pythonFiles/vscode_pytest/__init__.py | 2 +- 3 files changed, 44 insertions(+), 45 deletions(-) diff --git a/pythonFiles/tests/pytestadapter/expected_discovery_test_output.py b/pythonFiles/tests/pytestadapter/expected_discovery_test_output.py index 2d86710e776b..b37783d81cbb 100644 --- a/pythonFiles/tests/pytestadapter/expected_discovery_test_output.py +++ b/pythonFiles/tests/pytestadapter/expected_discovery_test_output.py @@ -349,48 +349,6 @@ "type_": "folder", "id_": os.fspath(dual_level_nested_folder_path), "children": [ - { - "name": "test_top_folder.py", - "path": os.fspath(test_top_folder_path), - "type_": "file", - "id_": os.fspath(test_top_folder_path), - "children": [ - { - "name": "test_top_function_t", - "path": os.fspath(test_top_folder_path), - "lineno": find_test_line_number( - "test_top_function_t", - test_top_folder_path, - ), - "type_": "test", - "id_": get_absolute_test_id( - "dual_level_nested_folder/test_top_folder.py::test_top_function_t", - test_top_folder_path, - ), - "runID": get_absolute_test_id( - "dual_level_nested_folder/test_top_folder.py::test_top_function_t", - test_top_folder_path, - ), - }, - { - "name": "test_top_function_f", - "path": os.fspath(test_top_folder_path), - "lineno": find_test_line_number( - "test_top_function_f", - test_top_folder_path, - ), - "type_": "test", - "id_": get_absolute_test_id( - "dual_level_nested_folder/test_top_folder.py::test_top_function_f", - test_top_folder_path, - ), - "runID": get_absolute_test_id( - "dual_level_nested_folder/test_top_folder.py::test_top_function_f", - test_top_folder_path, - ), - }, - ], - }, { "name": "nested_folder_one", "path": os.fspath(test_nested_folder_one_path), @@ -441,6 +399,48 @@ } ], }, + { + "name": "test_top_folder.py", + "path": os.fspath(test_top_folder_path), + "type_": "file", + "id_": os.fspath(test_top_folder_path), + "children": [ + { + "name": "test_top_function_t", + "path": os.fspath(test_top_folder_path), + "lineno": find_test_line_number( + "test_top_function_t", + test_top_folder_path, + ), + "type_": "test", + "id_": get_absolute_test_id( + "dual_level_nested_folder/test_top_folder.py::test_top_function_t", + test_top_folder_path, + ), + "runID": get_absolute_test_id( + "dual_level_nested_folder/test_top_folder.py::test_top_function_t", + test_top_folder_path, + ), + }, + { + "name": "test_top_function_f", + "path": os.fspath(test_top_folder_path), + "lineno": find_test_line_number( + "test_top_function_f", + test_top_folder_path, + ), + "type_": "test", + "id_": get_absolute_test_id( + "dual_level_nested_folder/test_top_folder.py::test_top_function_f", + test_top_folder_path, + ), + "runID": get_absolute_test_id( + "dual_level_nested_folder/test_top_folder.py::test_top_function_f", + test_top_folder_path, + ), + }, + ], + }, ], } ], diff --git a/pythonFiles/tests/pytestadapter/test_discovery.py b/pythonFiles/tests/pytestadapter/test_discovery.py index 8cc10e6ae9f1..2630ddef68b0 100644 --- a/pythonFiles/tests/pytestadapter/test_discovery.py +++ b/pythonFiles/tests/pytestadapter/test_discovery.py @@ -233,8 +233,7 @@ def test_pytest_config_file(): actual = runner_with_cwd( [ "--collect-only", - "-c", - "tests/pytest.ini", + "tests/", ], TEST_DATA_PATH / "root", ) diff --git a/pythonFiles/vscode_pytest/__init__.py b/pythonFiles/vscode_pytest/__init__.py index 43f9570aa982..a565fbf930a6 100644 --- a/pythonFiles/vscode_pytest/__init__.py +++ b/pythonFiles/vscode_pytest/__init__.py @@ -540,7 +540,7 @@ def create_session_node(session: pytest.Session) -> TestNode: """ node_path = get_node_path(session) return { - "name": session.name, + "name": node_path.name, "path": node_path, "type_": "folder", "children": [], From 22a2185775ae3aee940acbc787ef81ce86794aa8 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Mon, 29 Jan 2024 13:15:37 -0800 Subject: [PATCH 2/2] rename to support alphabetical ordering --- .../test_bottom_folder.py | 0 .../expected_discovery_test_output.py | 106 +++++++++--------- .../expected_execution_test_output.py | 14 +-- .../tests/pytestadapter/test_execution.py | 4 +- 4 files changed, 62 insertions(+), 62 deletions(-) rename pythonFiles/tests/pytestadapter/.data/dual_level_nested_folder/{nested_folder_one => z_nested_folder_one}/test_bottom_folder.py (100%) diff --git a/pythonFiles/tests/pytestadapter/.data/dual_level_nested_folder/nested_folder_one/test_bottom_folder.py b/pythonFiles/tests/pytestadapter/.data/dual_level_nested_folder/z_nested_folder_one/test_bottom_folder.py similarity index 100% rename from pythonFiles/tests/pytestadapter/.data/dual_level_nested_folder/nested_folder_one/test_bottom_folder.py rename to pythonFiles/tests/pytestadapter/.data/dual_level_nested_folder/z_nested_folder_one/test_bottom_folder.py diff --git a/pythonFiles/tests/pytestadapter/expected_discovery_test_output.py b/pythonFiles/tests/pytestadapter/expected_discovery_test_output.py index b37783d81cbb..d4e91f56b5fe 100644 --- a/pythonFiles/tests/pytestadapter/expected_discovery_test_output.py +++ b/pythonFiles/tests/pytestadapter/expected_discovery_test_output.py @@ -317,7 +317,7 @@ # └── test_top_folder.py # └── test_top_function_t # └── test_top_function_f -# └── nested_folder_one +# └── z_nested_folder_one # └── test_bottom_folder.py # └── test_bottom_function_t # └── test_bottom_function_f @@ -326,14 +326,14 @@ TEST_DATA_PATH / "dual_level_nested_folder" / "test_top_folder.py" ) -test_nested_folder_one_path = ( - TEST_DATA_PATH / "dual_level_nested_folder" / "nested_folder_one" +test_z_nested_folder_one_path = ( + TEST_DATA_PATH / "dual_level_nested_folder" / "z_nested_folder_one" ) test_bottom_folder_path = ( TEST_DATA_PATH / "dual_level_nested_folder" - / "nested_folder_one" + / "z_nested_folder_one" / "test_bottom_folder.py" ) @@ -350,10 +350,52 @@ "id_": os.fspath(dual_level_nested_folder_path), "children": [ { - "name": "nested_folder_one", - "path": os.fspath(test_nested_folder_one_path), + "name": "test_top_folder.py", + "path": os.fspath(test_top_folder_path), + "type_": "file", + "id_": os.fspath(test_top_folder_path), + "children": [ + { + "name": "test_top_function_t", + "path": os.fspath(test_top_folder_path), + "lineno": find_test_line_number( + "test_top_function_t", + test_top_folder_path, + ), + "type_": "test", + "id_": get_absolute_test_id( + "dual_level_nested_folder/test_top_folder.py::test_top_function_t", + test_top_folder_path, + ), + "runID": get_absolute_test_id( + "dual_level_nested_folder/test_top_folder.py::test_top_function_t", + test_top_folder_path, + ), + }, + { + "name": "test_top_function_f", + "path": os.fspath(test_top_folder_path), + "lineno": find_test_line_number( + "test_top_function_f", + test_top_folder_path, + ), + "type_": "test", + "id_": get_absolute_test_id( + "dual_level_nested_folder/test_top_folder.py::test_top_function_f", + test_top_folder_path, + ), + "runID": get_absolute_test_id( + "dual_level_nested_folder/test_top_folder.py::test_top_function_f", + test_top_folder_path, + ), + }, + ], + }, + { + "name": "z_nested_folder_one", + "path": os.fspath(test_z_nested_folder_one_path), "type_": "folder", - "id_": os.fspath(test_nested_folder_one_path), + "id_": os.fspath(test_z_nested_folder_one_path), "children": [ { "name": "test_bottom_folder.py", @@ -370,11 +412,11 @@ ), "type_": "test", "id_": get_absolute_test_id( - "dual_level_nested_folder/nested_folder_one/test_bottom_folder.py::test_bottom_function_t", + "dual_level_nested_folder/z_nested_folder_one/test_bottom_folder.py::test_bottom_function_t", test_bottom_folder_path, ), "runID": get_absolute_test_id( - "dual_level_nested_folder/nested_folder_one/test_bottom_folder.py::test_bottom_function_t", + "dual_level_nested_folder/z_nested_folder_one/test_bottom_folder.py::test_bottom_function_t", test_bottom_folder_path, ), }, @@ -387,11 +429,11 @@ ), "type_": "test", "id_": get_absolute_test_id( - "dual_level_nested_folder/nested_folder_one/test_bottom_folder.py::test_bottom_function_f", + "dual_level_nested_folder/z_nested_folder_one/test_bottom_folder.py::test_bottom_function_f", test_bottom_folder_path, ), "runID": get_absolute_test_id( - "dual_level_nested_folder/nested_folder_one/test_bottom_folder.py::test_bottom_function_f", + "dual_level_nested_folder/z_nested_folder_one/test_bottom_folder.py::test_bottom_function_f", test_bottom_folder_path, ), }, @@ -399,48 +441,6 @@ } ], }, - { - "name": "test_top_folder.py", - "path": os.fspath(test_top_folder_path), - "type_": "file", - "id_": os.fspath(test_top_folder_path), - "children": [ - { - "name": "test_top_function_t", - "path": os.fspath(test_top_folder_path), - "lineno": find_test_line_number( - "test_top_function_t", - test_top_folder_path, - ), - "type_": "test", - "id_": get_absolute_test_id( - "dual_level_nested_folder/test_top_folder.py::test_top_function_t", - test_top_folder_path, - ), - "runID": get_absolute_test_id( - "dual_level_nested_folder/test_top_folder.py::test_top_function_t", - test_top_folder_path, - ), - }, - { - "name": "test_top_function_f", - "path": os.fspath(test_top_folder_path), - "lineno": find_test_line_number( - "test_top_function_f", - test_top_folder_path, - ), - "type_": "test", - "id_": get_absolute_test_id( - "dual_level_nested_folder/test_top_folder.py::test_top_function_f", - test_top_folder_path, - ), - "runID": get_absolute_test_id( - "dual_level_nested_folder/test_top_folder.py::test_top_function_f", - test_top_folder_path, - ), - }, - ], - }, ], } ], diff --git a/pythonFiles/tests/pytestadapter/expected_execution_test_output.py b/pythonFiles/tests/pytestadapter/expected_execution_test_output.py index 44f3d3d0abce..cf8997a252d3 100644 --- a/pythonFiles/tests/pytestadapter/expected_execution_test_output.py +++ b/pythonFiles/tests/pytestadapter/expected_execution_test_output.py @@ -308,7 +308,7 @@ # └── test_top_folder.py # └── test_top_function_t: success # └── test_top_function_f: failure -# └── nested_folder_one +# └── z_nested_folder_one # └── test_bottom_folder.py # └── test_bottom_function_t: success # └── test_bottom_function_f: failure @@ -318,7 +318,7 @@ dual_level_nested_folder_bottom_path = ( TEST_DATA_PATH / "dual_level_nested_folder" - / "nested_folder_one" + / "z_nested_folder_one" / "test_bottom_folder.py" ) dual_level_nested_folder_execution_expected_output = { @@ -345,11 +345,11 @@ "subtest": None, }, get_absolute_test_id( - "nested_folder_one/test_bottom_folder.py::test_bottom_function_t", + "z_nested_folder_one/test_bottom_folder.py::test_bottom_function_t", dual_level_nested_folder_bottom_path, ): { "test": get_absolute_test_id( - "nested_folder_one/test_bottom_folder.py::test_bottom_function_t", + "z_nested_folder_one/test_bottom_folder.py::test_bottom_function_t", dual_level_nested_folder_bottom_path, ), "outcome": "success", @@ -358,11 +358,11 @@ "subtest": None, }, get_absolute_test_id( - "nested_folder_one/test_bottom_folder.py::test_bottom_function_f", + "z_nested_folder_one/test_bottom_folder.py::test_bottom_function_f", dual_level_nested_folder_bottom_path, ): { "test": get_absolute_test_id( - "nested_folder_one/test_bottom_folder.py::test_bottom_function_f", + "z_nested_folder_one/test_bottom_folder.py::test_bottom_function_f", dual_level_nested_folder_bottom_path, ), "outcome": "failure", @@ -479,7 +479,7 @@ dual_level_nested_folder_bottom_path = ( TEST_DATA_PATH / "dual_level_nested_folder" - / "nested_folder_one" + / "z_nested_folder_one" / "test_bottom_folder.py" ) unittest_folder_add_path = TEST_DATA_PATH / "unittest_folder" / "test_add.py" diff --git a/pythonFiles/tests/pytestadapter/test_execution.py b/pythonFiles/tests/pytestadapter/test_execution.py index dd32b61fa262..767d54a6cabe 100644 --- a/pythonFiles/tests/pytestadapter/test_execution.py +++ b/pythonFiles/tests/pytestadapter/test_execution.py @@ -193,8 +193,8 @@ def test_bad_id_error_execution(): [ "dual_level_nested_folder/test_top_folder.py::test_top_function_t", "dual_level_nested_folder/test_top_folder.py::test_top_function_f", - "dual_level_nested_folder/nested_folder_one/test_bottom_folder.py::test_bottom_function_t", - "dual_level_nested_folder/nested_folder_one/test_bottom_folder.py::test_bottom_function_f", + "dual_level_nested_folder/z_nested_folder_one/test_bottom_folder.py::test_bottom_function_t", + "dual_level_nested_folder/z_nested_folder_one/test_bottom_folder.py::test_bottom_function_f", ], expected_execution_test_output.dual_level_nested_folder_execution_expected_output, ),