From 5238e08e3f4acef5edc4f18d74f379d05e0f4e47 Mon Sep 17 00:00:00 2001 From: Pavel Karateev Date: Mon, 2 Dec 2024 11:20:38 +0100 Subject: [PATCH] PCQA-724 Mute all failing Python 3.9 debug tests Tickets for muted tests ... - PCQA-592 - PCQA-731 - PCQA-732 - PCQA-733 - PCQA-734 - PCQA-735 - PCQA-736 - PCQA-737 - PCQA-738 - PCQA-739 Also ... - Re-written `test_tracing_on_top_level.py` to allow test-muting case-by-case - Re-written handling decorator to avoid global variables usage GitOrigin-RevId: 53eff72581862e963e276b8803ec5004e332348b --- .../pydev/_pydevd_bundle/pydevd_constants.py | 2 + .../pydev/pydev_tests/test_pyserver.py | 2 + .../test_bytecode_modification.py | 2 + .../test_collect_try_except_info.py | 4 ++ .../pydev/pydev_tests_python/test_debugger.py | 11 ++- .../test_smart_step_into.py | 4 +- .../test_tracing_on_top_level.py | 68 +++++++++++++------ 7 files changed, 67 insertions(+), 26 deletions(-) diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py b/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py index e967ac671e0c..926dad973ad8 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py @@ -142,10 +142,12 @@ try: IS_PY36_OR_LESSER = sys.version_info[:2] <= (3, 6) IS_PY38 = sys.version_info[0] == 3 and sys.version_info[1] == 8 IS_PY38_OR_GREATER = sys.version_info >= (3, 8) + IS_PY39 = sys.version_info[0] == 3 and sys.version_info[1] == 9 IS_PY39_OR_GREATER = sys.version_info >= (3, 9) IS_PY311 = sys.version_info[0] == 3 and sys.version_info[1] == 11 IS_PY311_OR_GREATER = sys.version_info >= (3, 11) IS_PY312_OR_GREATER = sys.version_info >= (3, 12) + IS_PY312_OR_LESSER = sys.version_info[:2] <= (3, 12) elif sys.version_info[0] == 2 and sys.version_info[1] == 7: IS_PY27 = True elif sys.version_info[0] == 2 and sys.version_info[1] == 4: diff --git a/python/helpers/pydev/pydev_tests/test_pyserver.py b/python/helpers/pydev/pydev_tests/test_pyserver.py index 475bd68c7120..9cd332a5e514 100644 --- a/python/helpers/pydev/pydev_tests/test_pyserver.py +++ b/python/helpers/pydev/pydev_tests/test_pyserver.py @@ -4,6 +4,7 @@ import sys import pytest from _pydev_imps._pydev_saved_modules import thread +from _pydevd_bundle.pydevd_constants import IS_PY39_OR_GREATER start_new_thread = thread.start_new_thread @@ -88,6 +89,7 @@ class TestCPython(unittest.TestCase): return msg + @pytest.mark.xfail(IS_PY39_OR_GREATER, reason="PCQA-731") def test_completion_sockets_and_messages(self): t, socket = self.create_connections() self.socket = socket diff --git a/python/helpers/pydev/pydev_tests_python/test_bytecode_modification.py b/python/helpers/pydev/pydev_tests_python/test_bytecode_modification.py index 9f3ec427857b..9bb36c988afc 100644 --- a/python/helpers/pydev/pydev_tests_python/test_bytecode_modification.py +++ b/python/helpers/pydev/pydev_tests_python/test_bytecode_modification.py @@ -8,6 +8,7 @@ import pytest from _pydevd_frame_eval.pydevd_modify_bytecode import insert_code, \ add_jump_instruction, IS_PY310_OR_GREATER +from _pydevd_bundle.pydevd_constants import IS_PY39 from opcode import EXTENDED_ARG TRACE_MESSAGE = "Trace called" @@ -817,6 +818,7 @@ class TestInsertCode(unittest.TestCase): @pytest.mark.skipif( IS_PY310_OR_GREATER, reason="Test is specific for Python versions < 3.10") + @pytest.mark.xfail(IS_PY39, reason="PCQA-732") def testing_add_extended_arg(self): def backtrack(move_list, board_p, number_p): diff --git a/python/helpers/pydev/pydev_tests_python/test_collect_try_except_info.py b/python/helpers/pydev/pydev_tests_python/test_collect_try_except_info.py index 071f5beb8005..86e8370e3a0f 100644 --- a/python/helpers/pydev/pydev_tests_python/test_collect_try_except_info.py +++ b/python/helpers/pydev/pydev_tests_python/test_collect_try_except_info.py @@ -4,6 +4,8 @@ import sys import traceback from _pydevd_bundle.pydevd_collect_try_except_info import collect_try_except_info, collect_return_info +from _pydevd_bundle.pydevd_constants import IS_PY39 +from _pydevd_bundle.pydevd_constants import IS_PY39_OR_GREATER from pydev_tests_python.debugger_unittest import IS_CPYTHON, IS_JYTHON, IS_PY2, IS_PY38_OR_GREATER @@ -158,6 +160,7 @@ import pytest @pytest.mark.skipif(not IS_CPYTHON, reason='CPython only test.') +@pytest.mark.xfail(IS_PY39_OR_GREATER, reason="PCQA-733") def test_collect_try_except_info(data_regression): method_to_info = {} for key, method in sorted(dict(globals()).items()): @@ -185,6 +188,7 @@ def test_collect_try_except_info(data_regression): data_regression.check(method_to_info) +@pytest.mark.xfail(IS_PY39, reason="PCQA-734") def test_collect_try_except_info2(): def method(): diff --git a/python/helpers/pydev/pydev_tests_python/test_debugger.py b/python/helpers/pydev/pydev_tests_python/test_debugger.py index 5cb9d8013816..226b65b293c2 100644 --- a/python/helpers/pydev/pydev_tests_python/test_debugger.py +++ b/python/helpers/pydev/pydev_tests_python/test_debugger.py @@ -17,7 +17,12 @@ from pydev_tests_python.debugger_unittest import (CMD_SET_PROPERTY_TRACE, REASON IS_APPVEYOR, wait_for_condition, CMD_GET_FRAME, CMD_GET_BREAKPOINT_EXCEPTION, CMD_THREAD_SUSPEND, CMD_STEP_OVER, REASON_STEP_OVER, CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION, CMD_THREAD_RESUME_SINGLE_NOTIFICATION, IS_PY37_OR_GREATER, IS_PY38_OR_GREATER) -from _pydevd_bundle.pydevd_constants import IS_WINDOWS, IS_PY38, GET_FRAME_RETURN_GROUP +from _pydevd_bundle.pydevd_constants import IS_WINDOWS +from _pydevd_bundle.pydevd_constants import GET_FRAME_RETURN_GROUP +from _pydevd_bundle.pydevd_constants import IS_PY38 +from _pydevd_bundle.pydevd_constants import IS_PY39_OR_GREATER +from _pydevd_bundle.pydevd_constants import IS_PY312_OR_LESSER + try: from urllib import unquote @@ -1955,6 +1960,7 @@ def test_case_dump_threads_to_stderr(case_setup): writer.finished_ok = True +@pytest.mark.xfail(IS_PY39_OR_GREATER and IS_PY312_OR_LESSER, reason="PCQA-735") def test_stop_on_start_regular(case_setup): with case_setup.test_file('_debugger_case_simple_calls.py') as writer: @@ -2010,7 +2016,7 @@ def test_generator_cases(case_setup, filename): writer.finished_ok = True - +@pytest.mark.xfail(IS_PY39_OR_GREATER and IS_PY312_OR_LESSER, reason="PCQA-736") def test_stop_on_start_m_switch(case_setup_m_switch): with case_setup_m_switch.test_file() as writer: @@ -2024,6 +2030,7 @@ def test_stop_on_start_m_switch(case_setup_m_switch): writer.finished_ok = True +@pytest.mark.xfail(IS_PY39_OR_GREATER and IS_PY312_OR_LESSER, reason="PCQA-737") def test_stop_on_start_entry_point(case_setup_m_switch_entry_point): with case_setup_m_switch_entry_point.test_file() as writer: diff --git a/python/helpers/pydev/pydev_tests_python/test_smart_step_into.py b/python/helpers/pydev/pydev_tests_python/test_smart_step_into.py index df6d6e62c3c4..158674dafc44 100644 --- a/python/helpers/pydev/pydev_tests_python/test_smart_step_into.py +++ b/python/helpers/pydev/pydev_tests_python/test_smart_step_into.py @@ -2,9 +2,9 @@ from __future__ import print_function import pytest -from _pydevd_bundle.pydevd_constants import IS_PY38 from _pydevd_bundle.smart_step_into import get_stepping_variants from _pydevd_bundle.pydevd_constants import IS_PY38 +from _pydevd_bundle.pydevd_constants import IS_PY39 @pytest.fixture @@ -125,7 +125,7 @@ def test_candidates_for_consecutive_calls_py3(consecutive_calls): assert variants[4].argval == '__add__' -@pytest.mark.xfail(IS_PY38, reason="PCQA-592") +@pytest.mark.xfail(IS_PY38 or IS_PY39, reason="PCQA-592") def test_candidates_for_returned_object_method(returned_object_method): variants = list(get_stepping_variants(returned_object_method)) assert len(variants) == 3 diff --git a/python/helpers/pydev/pydev_tests_python/test_tracing_on_top_level.py b/python/helpers/pydev/pydev_tests_python/test_tracing_on_top_level.py index 59b8f6defa3d..b2996f76aa70 100644 --- a/python/helpers/pydev/pydev_tests_python/test_tracing_on_top_level.py +++ b/python/helpers/pydev/pydev_tests_python/test_tracing_on_top_level.py @@ -1,6 +1,8 @@ from pydevd import PyDB import pytest from pydev_tests_python.debugger_unittest import IS_CPYTHON +from _pydevd_bundle.pydevd_constants import IS_PY39_OR_GREATER +from _pydevd_bundle.pydevd_constants import IS_PY312_OR_LESSER DEBUG = False @@ -128,21 +130,19 @@ def trace_top_level_unhandled(trace_top_level): return trace_top_level -_expected_functions_to_test = 0 +class Handle(object): + def __init__(self, is_handled=True): + self.is_handled = is_handled + self.count = 0 + + def __call__(self, func): + func.__handled__ = self.is_handled + self.count += 1 + return func -def mark_handled(func): - global _expected_functions_to_test - _expected_functions_to_test += 1 - func.__handled__ = True - return func - - -def mark_unhandled(func): - global _expected_functions_to_test - _expected_functions_to_test += 1 - func.__handled__ = False - return func +mark_handled = Handle() +mark_unhandled = Handle(False) #------------------------------------------------------------------------------------------- Handled @@ -454,19 +454,43 @@ def _replay_events(collected, trace_top_level_unhandled): raise AssertionError('Unexpected: %s' % (event,)) -def _collect_target_functions(): -# return [raise_unhandled10] - ret = [] - for _key, method in sorted(dict(globals()).items()): - if hasattr(method, '__handled__'): - ret.append(method) +_expected_tested = ( + # handled + raise_handled_exception, + raise_handled_exception2, + raise_handled_exception3, + raise_handled_exception3a, + raise_handled_exception4, + raise_handled, + raise_handled2, + pytest.param(raise_handled9, marks=pytest.mark.xfail(IS_PY39_OR_GREATER and IS_PY312_OR_LESSER, reason="PCQA-739")), + pytest.param(raise_handled10, marks=pytest.mark.xfail(IS_PY39_OR_GREATER and IS_PY312_OR_LESSER, reason="PCQA-738")), - assert len(ret) == _expected_functions_to_test - return ret + # unhandled + raise_unhandled_exception, + raise_unhandled_exception_not_in_except_clause, + raise_unhandled, + raise_unhandled2, + raise_unhandled3, + raise_unhandled4, + raise_unhandled5, + raise_unhandled6, + raise_unhandled7, + raise_unhandled8, + raise_unhandled9, + raise_unhandled10, + raise_unhandled11, + raise_unhandled12, + reraise_handled_exception, +) + + +def test_expected_number_tested(): + assert len(_expected_tested) == mark_handled.count + mark_unhandled.count @pytest.mark.skipif(not IS_CPYTHON, reason='try..except info only available on CPython') -@pytest.mark.parametrize("func", _collect_target_functions()) +@pytest.mark.parametrize("func", _expected_tested) def test_tracing_on_top_level_unhandled(trace_top_level_unhandled, func): trace_top_level_unhandled.set_target_func(func)