[python] PCQA-1466 allow running Python 2 helpers tests

(cherry picked from commit 1aeb8996b00683167c278ba924ab370059248c76)

IJ-MR-187159

GitOrigin-RevId: 2fa35f5adbf8e10e82689f04eddf4a35e4ac8ecf
This commit is contained in:
Pavel Karateev
2026-01-07 22:59:29 +00:00
committed by intellij-monorepo-bot
parent 7a2794ae3e
commit 7e6b346402
4 changed files with 32 additions and 2 deletions
+2
View File
@@ -0,0 +1,2 @@
behave==1.3.3
pytest==4.6.11
+19
View File
@@ -0,0 +1,19 @@
import os
import sys
import pytest
current_dir = os.path.dirname(os.path.abspath(__file__))
python_plugin_dir = os.path.abspath(os.path.join(current_dir, '..'))
helpers_dir = os.path.join(python_plugin_dir, "helpers")
pycharm_dir = os.path.join(helpers_dir, "pycharm")
py3only_dir = os.path.join(helpers_dir, "py3only")
sys.path.insert(0, helpers_dir)
sys.path.insert(0, pycharm_dir)
sys.path.insert(0, py3only_dir)
exit_code = pytest.main(["--junit-xml=.tox/reports/junit-py27.xml", "tests"])
sys.exit(exit_code)
@@ -5,6 +5,7 @@ import pytest
from pycharm._jb_unittest_runner import build_unittest_args
@pytest.mark.skipif(sys.version_info < (3, 0), reason="Python 3 is required")
def test_path_doesnt_exist():
pattern = r"No such file or directory: 'test_foo.py'"
with pytest.raises(OSError, match=pattern):
@@ -12,6 +13,7 @@ def test_path_doesnt_exist():
@pytest.mark.skipif(sys.version_info < (3, 0), reason="Python 3 is required")
def test_targets():
assert build_unittest_args(
path=None,
@@ -26,6 +28,7 @@ def test_targets():
]
@pytest.mark.skipif(sys.version_info < (3, 0), reason="Python 3 is required")
def test_quiet_discover(tmp_path):
assert build_unittest_args(
path=str(tmp_path),
@@ -44,6 +47,7 @@ def test_quiet_discover(tmp_path):
]
@pytest.mark.skipif(sys.version_info < (3, 0), reason="Python 3 is required")
def test_verbose_discover(tmp_path):
assert build_unittest_args(
path=str(tmp_path),
@@ -70,7 +74,6 @@ def test_python2(tmp_path):
additional_args=[],
verbose=True,
project_dir="/project_dir",
python_version=(2, 7),
) == [
"python -m unittest",
"discover",
@@ -93,7 +96,6 @@ def test_python2_and_path_is_file(tmp_path):
additional_args=[],
verbose=True,
project_dir="/project_dir",
python_version=(2, 7),
) == [
"python -m unittest",
"discover",
@@ -125,6 +127,7 @@ def test_python3_and_path_is_file(tmp_path):
]
@pytest.mark.skipif(sys.version_info < (3, 0), reason="Python 3 is required")
def test_user_args():
assert build_unittest_args(
path=None,
@@ -141,6 +144,7 @@ def test_user_args():
]
@pytest.mark.skipif(sys.version_info < (3, 0), reason="Python 3 is required")
def test_user_overrides_verbosity():
assert build_unittest_args(
path=None,
@@ -156,6 +160,7 @@ def test_user_overrides_verbosity():
]
@pytest.mark.skipif(sys.version_info < (3, 0), reason="Python 3 is required")
def test_rerun_failed_tests():
assert build_unittest_args(
path=None,
@@ -1,9 +1,12 @@
import sys
import pytest
pytest_plugins = "pytester"
# PY-84850
@pytest.mark.skipif(sys.version_info < (3, 0), reason="Python 3 is required")
def test_teamcity_plugin_with_xdist(pytester):
pytester.makepyfile("""
def test_example_1():
@@ -25,6 +28,7 @@ def test_teamcity_plugin_with_xdist(pytester):
# PY-84850
@pytest.mark.skipif(sys.version_info < (3, 0), reason="Python 3 is required")
def test_teamcity_plugin_without_xdist(pytester):
pytester.makepyfile("""
def test_basic():