From fddc5e1b793fc99b0d883e3500ab5dd97099dbc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Tue, 28 Jan 2025 15:58:56 +0200 Subject: [PATCH] PY-56529: Fix test runner replacing "." in test parameter with "::" GitOrigin-RevId: ab6a6e91d19e1279e191c474cf20247099c5cdf4 --- python/helpers/pycharm/_jb_runner_tools.py | 4 ++-- .../env/pytest/parametrized/test_pytest_parametrized.py | 2 +- .../jetbrains/env/python/testing/PythonPyTestingTest.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/helpers/pycharm/_jb_runner_tools.py b/python/helpers/pycharm/_jb_runner_tools.py index 211d9b25f226..b7de45cc66c6 100644 --- a/python/helpers/pycharm/_jb_runner_tools.py +++ b/python/helpers/pycharm/_jb_runner_tools.py @@ -289,10 +289,10 @@ def jb_patch_targets(targets, fs_glue, old_python_glue, new_python_glue, fs_to_p def _patch_target(target): # /path/foo.py::parts.to.python - match = re.match("^(:?(.+)[.]py::)?(.+)$", target) + match = re.match("^(:?(.+)[.]py::)?([^\\[]+)(.*)$", target) assert match, "unexpected string: {0}".format(target) fs_part = match.group(2) - python_part = match.group(3).replace(old_python_glue, new_python_glue) + python_part = match.group(3).replace(old_python_glue, new_python_glue) + match.group(4) if python_parts_action is not None: python_part = python_parts_action(fs_part, python_part) if fs_part: diff --git a/python/testData/testRunner/env/pytest/parametrized/test_pytest_parametrized.py b/python/testData/testRunner/env/pytest/parametrized/test_pytest_parametrized.py index fb6f14b442a9..4505dc73efa5 100644 --- a/python/testData/testRunner/env/pytest/parametrized/test_pytest_parametrized.py +++ b/python/testData/testRunner/env/pytest/parametrized/test_pytest_parametrized.py @@ -1,6 +1,6 @@ import pytest @pytest.mark.parametrize("test_input,expected", [ - ("three plus file", 8), + ("three.plus file", 8), ("(2)+(4)", 6), (" six times nine.", 42), ]) diff --git a/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java b/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java index 24c4ba5f99bb..7c39f1bb546e 100644 --- a/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java +++ b/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java @@ -295,7 +295,7 @@ public final class PythonPyTestingTest extends PyEnvTestCase { "[root](-)\n" + ".test_pytest_parametrized(-)\n" + "..test_eval(-)\n" + - "...(three plus file-8)(-)\n" + + "...(three_plus file-8)(-)\n" + ((runner.getCurrentRerunStep() == 0) ? "...((2)+(4)-6)(+)\n" : "") + "...( six times nine_-42)(-)\n", runner.getFormattedTestTree()); } @@ -326,7 +326,7 @@ public final class PythonPyTestingTest extends PyEnvTestCase { else { configuration.setAdditionalArguments("--debug"); } - configuration.setMetaInfo("test_eval[three plus file-8]"); + configuration.setMetaInfo("test_eval[three.plus file-8]"); } }; } @@ -342,7 +342,7 @@ public final class PythonPyTestingTest extends PyEnvTestCase { [root](-) .test_pytest_parametrized(-) ..test_eval(-) - ...(three plus file-8)(-) + ...(three_plus file-8)(-) """, runner.getFormattedTestTree()); } });