From fad1affcc4a1309f551d955156a8684fe8583f8e Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Mon, 29 Jan 2024 14:01:39 -0800 Subject: [PATCH] changes to support pytest 8 (#22799) fixes: https://github.com/microsoft/vscode-python/issues/22798 --- .../test_bottom_folder.py | 0 .../expected_discovery_test_output.py | 22 +++++++++---------- .../expected_execution_test_output.py | 14 ++++++------ .../tests/pytestadapter/test_discovery.py | 3 +-- .../tests/pytestadapter/test_execution.py | 4 ++-- pythonFiles/vscode_pytest/__init__.py | 2 +- 6 files changed, 22 insertions(+), 23 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 2d86710e776b..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" ) @@ -392,10 +392,10 @@ ], }, { - "name": "nested_folder_one", - "path": os.fspath(test_nested_folder_one_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", @@ -412,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, ), }, @@ -429,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, ), }, 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_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/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, ), 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": [],