From aacdfc9b98fa7fec96b6a3d281fdccb4a64ba443 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 28 Jun 2023 11:04:46 +0100 Subject: [PATCH 1/9] Stop using the deprecated `locale.getdefaultlocale()` function Signed-off-by: Pedro Algarvio --- changelog/64565.changed.md | 1 + salt/__init__.py | 10 +++++----- salt/client/ssh/ssh_py_shim.py | 10 +++++----- salt/grains/core.py | 4 +--- 4 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 changelog/64565.changed.md diff --git a/changelog/64565.changed.md b/changelog/64565.changed.md new file mode 100644 index 00000000000..1faa9c42991 --- /dev/null +++ b/changelog/64565.changed.md @@ -0,0 +1 @@ +Stop using the deprecated `locale.getdefaultlocale()` function diff --git a/salt/__init__.py b/salt/__init__.py index 6649fdf5683..30880b10acc 100644 --- a/salt/__init__.py +++ b/salt/__init__.py @@ -93,14 +93,14 @@ def __define_global_system_encoding_variable__(): import locale try: - encoding = locale.getdefaultlocale()[-1] - except ValueError: - # A bad locale setting was most likely found: - # https://github.com/saltstack/salt/issues/26063 - pass + encoding = locale.getencoding() + except AttributeError: + # Python < 3.11 + encoding = locale.getpreferredencoding(do_setlocale=True) # This is now garbage collectable del locale + if not encoding: # This is most likely ascii which is not the best but we were # unable to find a better encoding. If this fails, we fall all diff --git a/salt/client/ssh/ssh_py_shim.py b/salt/client/ssh/ssh_py_shim.py index b77749f4953..9b8f9e0f658 100644 --- a/salt/client/ssh/ssh_py_shim.py +++ b/salt/client/ssh/ssh_py_shim.py @@ -67,14 +67,14 @@ def get_system_encoding(): import locale try: - encoding = locale.getdefaultlocale()[-1] - except ValueError: - # A bad locale setting was most likely found: - # https://github.com/saltstack/salt/issues/26063 - pass + encoding = locale.getencoding() + except AttributeError: + # Python < 3.11 + encoding = locale.getpreferredencoding(do_setlocale=True) # This is now garbage collectable del locale + if not encoding: # This is most likely ascii which is not the best but we were # unable to find a better encoding. If this fails, we fall all diff --git a/salt/grains/core.py b/salt/grains/core.py index 710c57f28fb..7dd350a3453 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -2698,10 +2698,8 @@ def locale_info(): ( grains["locale_info"]["defaultlanguage"], grains["locale_info"]["defaultencoding"], - ) = locale.getdefaultlocale() + ) = locale.getlocale() except Exception: # pylint: disable=broad-except - # locale.getdefaultlocale can ValueError!! Catch anything else it - # might do, per #2205 grains["locale_info"]["defaultlanguage"] = "unknown" grains["locale_info"]["defaultencoding"] = "unknown" grains["locale_info"]["detectedencoding"] = __salt_system_encoding__ From f4eea349844bab892e88ad787cb37a7ddc83fd48 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 28 Jun 2023 11:38:04 +0100 Subject: [PATCH 2/9] Stop accessing deprecated attributes Signed-off-by: Pedro Algarvio --- changelog/64565.changed.md | 5 ++++- .../modules/state/test_state_pillar_errors.py | 14 +++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/changelog/64565.changed.md b/changelog/64565.changed.md index 1faa9c42991..e400920c5c5 100644 --- a/changelog/64565.changed.md +++ b/changelog/64565.changed.md @@ -1 +1,4 @@ -Stop using the deprecated `locale.getdefaultlocale()` function +Some more deprecated code fixes: + +* Stop using the deprecated `locale.getdefaultlocale()` function +* Stop accessing deprecated attributes diff --git a/tests/pytests/integration/modules/state/test_state_pillar_errors.py b/tests/pytests/integration/modules/state/test_state_pillar_errors.py index 99dd5f175d0..26812cb71b5 100644 --- a/tests/pytests/integration/modules/state/test_state_pillar_errors.py +++ b/tests/pytests/integration/modules/state/test_state_pillar_errors.py @@ -16,8 +16,8 @@ def reset_pillar(salt_call_cli): finally: # Refresh pillar once all tests are done. ret = salt_call_cli.run("saltutil.refresh_pillar", wait=True) - assert ret.exitcode == 0 - assert ret.json is True + assert ret.returncode == 0 + assert ret.data is True @pytest.fixture @@ -77,8 +77,8 @@ def test_state_apply_aborts_on_pillar_error( shell_result = salt_cli.run( "state.apply", "sls-id-test", minion_tgt=salt_minion.id ) - assert shell_result.exitcode == 1 - assert shell_result.json == expected_comment + assert shell_result.returncode == 1 + assert shell_result.data == expected_comment @pytest.mark.usefixtures("testfile_path", "reset_pillar") @@ -117,7 +117,7 @@ def test_state_apply_continues_after_pillar_error_is_fixed( shell_result = salt_cli.run( "saltutil.refresh_pillar", minion_tgt=salt_minion.id ) - assert shell_result.exitcode == 0 + assert shell_result.returncode == 0 # run state.apply with fixed pillar render error with pytest.helpers.temp_file( @@ -128,7 +128,7 @@ def test_state_apply_continues_after_pillar_error_is_fixed( shell_result = salt_cli.run( "state.apply", "sls-id-test", minion_tgt=salt_minion.id ) - assert shell_result.exitcode == 0 - state_result = StateResult(shell_result.json) + assert shell_result.returncode == 0 + state_result = StateResult(shell_result.data) assert state_result.result is True assert state_result.changes == {"diff": "New file", "mode": "0644"} From 34f13a7632b2aedb42522f0f0bae3a499e325827 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 28 Jun 2023 11:43:23 +0100 Subject: [PATCH 3/9] `pathlib.Path.__enter__()` usage is deprecated and not required, a no-op Signed-off-by: Pedro Algarvio --- changelog/64565.changed.md | 1 + tests/pytests/integration/runners/test_saltutil.py | 4 ++-- tests/pytests/integration/states/test_file.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/changelog/64565.changed.md b/changelog/64565.changed.md index e400920c5c5..1933f94cb30 100644 --- a/changelog/64565.changed.md +++ b/changelog/64565.changed.md @@ -2,3 +2,4 @@ Some more deprecated code fixes: * Stop using the deprecated `locale.getdefaultlocale()` function * Stop accessing deprecated attributes +* `pathlib.Path.__enter__()` usage is deprecated and not required, a no-op diff --git a/tests/pytests/integration/runners/test_saltutil.py b/tests/pytests/integration/runners/test_saltutil.py index 179d1b7bf6a..22ae12285ac 100644 --- a/tests/pytests/integration/runners/test_saltutil.py +++ b/tests/pytests/integration/runners/test_saltutil.py @@ -85,13 +85,13 @@ def world(): return "world" """ - test_moduledir = salt_master.state_tree.base.paths[0] / "_{}".format(module_type) + test_moduledir = salt_master.state_tree.base.write_path / "_{}".format(module_type) test_moduledir.mkdir(parents=True, exist_ok=True) module_tempfile = salt_master.state_tree.base.temp_file( "_{}/{}.py".format(module_type, module_name), module_contents ) - with module_tempfile, test_moduledir: + with module_tempfile: salt_cmd = "saltutil.sync_{}".format(module_sync_functions[module_type]) ret = salt_run_cli.run(salt_cmd) assert ret.returncode == 0 diff --git a/tests/pytests/integration/states/test_file.py b/tests/pytests/integration/states/test_file.py index 01e9da69902..ec8aafb299d 100644 --- a/tests/pytests/integration/states/test_file.py +++ b/tests/pytests/integration/states/test_file.py @@ -1070,7 +1070,7 @@ def test_recurse( "{}.sls".format(sls_name), sls_contents ) - with sls_tempfile, test_tempdir: + with sls_tempfile: for _dir in "test1", "test2", "test3": test_tempdir.joinpath(_dir).mkdir(parents=True, exist_ok=True) @@ -1117,7 +1117,7 @@ def test_recurse_keep_symlinks_in_fileserver_root( "{}.sls".format(sls_name), sls_contents ) - with sls_tempfile, test_tempdir: + with sls_tempfile: for _dir in "test1", "test2", "test3": test_tempdir.joinpath(_dir).mkdir(parents=True, exist_ok=True) @@ -1169,7 +1169,7 @@ def test_recurse_keep_symlinks_outside_fileserver_root( "{}.sls".format(sls_name), sls_contents ) - with sls_tempfile, test_tempdir: + with sls_tempfile: for _dir in "test1", "test2", "test3": test_tempdir.joinpath(_dir).mkdir(parents=True, exist_ok=True) From a1a414813bbbcadc24f28dc3fde1a21fa76af53b Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Tue, 30 May 2023 11:13:19 -0500 Subject: [PATCH 4/9] stop double test_labels --- tests/conftest.py | 21 ++++++++++--------- .../modules/state/requisites/test_mixed.py | 1 - .../modules/state/requisites/test_require.py | 1 - .../modules/state/requisites/test_watch.py | 1 - .../functional/modules/state/test_state.py | 4 ---- tests/pytests/integration/cli/test_salt.py | 1 - tests/pytests/integration/cli/test_salt_cp.py | 1 - .../integration/cli/test_salt_deltaproxy.py | 2 -- .../pytests/unit/state/test_state_compiler.py | 1 - .../unit/state/test_state_format_slots.py | 9 -------- 10 files changed, 11 insertions(+), 31 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a7777c2cea6..2a158df7b2a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -577,6 +577,12 @@ def pytest_runtest_setup(item): ): item._skipped_by_mark = True pytest.skip(PRE_PYTEST_SKIP_REASON) + test_group_count = sum( + bool(item.get_closest_marker(group)) + for group in ("core_test", "slow_test", "flaky_jail") + ) + if test_group_count > 1: + raise pytest.UsageError("Tests can only be in one test group.") if item.get_closest_marker("core_test"): if not item.config.getoption("--core-tests"): @@ -596,16 +602,11 @@ def pytest_runtest_setup(item): "flaky jail tests are disabled, pass '--flaky-jail' to enable them.", _use_item_location=True, ) - if ( - not item.get_closest_marker("slow_test") - and not item.get_closest_marker("core_test") - and not item.get_closest_marker("flaky_jail") - ): - if not item.config.getoption("--no-fast-tests"): - raise pytest.skip.Exception( - "Fast tests are disabled, dont pass '--no-fast-tests' to enable them.", - _use_item_location=True, - ) + if test_group_count == 0 and not item.config.getoption("--no-fast-tests"): + raise pytest.skip.Exception( + "Fast tests are disabled, dont pass '--no-fast-tests' to enable them.", + _use_item_location=True, + ) requires_sshd_server_marker = item.get_closest_marker("requires_sshd_server") if requires_sshd_server_marker is not None: diff --git a/tests/pytests/functional/modules/state/requisites/test_mixed.py b/tests/pytests/functional/modules/state/requisites/test_mixed.py index 622e73b986e..64db52c2e63 100644 --- a/tests/pytests/functional/modules/state/requisites/test_mixed.py +++ b/tests/pytests/functional/modules/state/requisites/test_mixed.py @@ -322,7 +322,6 @@ def test_issue_46762_prereqs_on_a_state_with_unfulfilled_requirements( @pytest.mark.skip_on_darwin(reason="Test is broken on macosx") -@pytest.mark.slow_test def test_issue_30161_unless_and_onlyif_together(state, state_tree, tmp_path): """ test cmd.run using multiple unless options where the first cmd in the diff --git a/tests/pytests/functional/modules/state/requisites/test_require.py b/tests/pytests/functional/modules/state/requisites/test_require.py index 2fa84704519..b20d9f151ab 100644 --- a/tests/pytests/functional/modules/state/requisites/test_require.py +++ b/tests/pytests/functional/modules/state/requisites/test_require.py @@ -571,7 +571,6 @@ def test_issue_38683_require_order_failhard_combination(state, state_tree): assert ret[state_id].comment == "Failure!" -@pytest.mark.slow_test @pytest.mark.skip_on_windows def test_parallel_state_with_requires(state, state_tree): """ diff --git a/tests/pytests/functional/modules/state/requisites/test_watch.py b/tests/pytests/functional/modules/state/requisites/test_watch.py index 15eb9e8aa53..4b3bd645fa5 100644 --- a/tests/pytests/functional/modules/state/requisites/test_watch.py +++ b/tests/pytests/functional/modules/state/requisites/test_watch.py @@ -57,7 +57,6 @@ def test_watch_in_failure(state, state_tree): ) -@pytest.mark.slow_test def test_requisites_watch_any(state, state_tree): """ Call sls file containing several require_in and require. diff --git a/tests/pytests/functional/modules/state/test_state.py b/tests/pytests/functional/modules/state/test_state.py index 7640afaa882..f049a53c3b3 100644 --- a/tests/pytests/functional/modules/state/test_state.py +++ b/tests/pytests/functional/modules/state/test_state.py @@ -650,7 +650,6 @@ def test_issues_7905_and_8174_sls_syntax_error(state, state_tree): assert ret.errors == ["State 'C' in SLS 'badlist2' is not formed as a list"] -@pytest.mark.slow_test def test_retry_option(state, state_tree): """ test the retry option on a simple state with defaults @@ -752,7 +751,6 @@ def test_retry_option_success_parallel(state, state_tree, tmp_path): assert "Attempt 2" not in state_return.comment -@pytest.mark.slow_test def test_retry_option_eventual_success(state, state_tree, tmp_path): """ test a state with the retry option that should return True, eventually @@ -800,7 +798,6 @@ def test_retry_option_eventual_success(state, state_tree, tmp_path): @pytest.mark.skip_on_windows( reason="Skipped until parallel states can be fixed on Windows" ) -@pytest.mark.slow_test def test_retry_option_eventual_success_parallel(state, state_tree, tmp_path): """ test a state with the retry option that should return True, eventually @@ -849,7 +846,6 @@ def test_retry_option_eventual_success_parallel(state, state_tree, tmp_path): assert "Attempt 5" not in state_return.comment -@pytest.mark.slow_test def test_state_non_base_environment(state, state_tree_prod, tmp_path): """ test state.sls with saltenv using a nonbase environment diff --git a/tests/pytests/integration/cli/test_salt.py b/tests/pytests/integration/cli/test_salt.py index b9ddc6f23f1..8e360682e84 100644 --- a/tests/pytests/integration/cli/test_salt.py +++ b/tests/pytests/integration/cli/test_salt.py @@ -132,7 +132,6 @@ def test_exit_status_correct_usage(salt_cli, salt_minion): assert ret.returncode == salt.defaults.exitcodes.EX_OK, ret -@pytest.mark.slow_test @pytest.mark.skip_on_windows(reason="Windows does not support SIGINT") @pytest.mark.skip_initial_onedir_failure def test_interrupt_on_long_running_job(salt_cli, salt_master, salt_minion): diff --git a/tests/pytests/integration/cli/test_salt_cp.py b/tests/pytests/integration/cli/test_salt_cp.py index db4a1519d66..9c303e7c9b4 100644 --- a/tests/pytests/integration/cli/test_salt_cp.py +++ b/tests/pytests/integration/cli/test_salt_cp.py @@ -32,7 +32,6 @@ def dest_testfile(): dst.unlink() -@pytest.mark.slow_test @pytest.mark.windows_whitelisted @pytest.mark.core_test def test_cp_testfile(salt_minion, salt_cp_cli, source_testfile, dest_testfile): diff --git a/tests/pytests/integration/cli/test_salt_deltaproxy.py b/tests/pytests/integration/cli/test_salt_deltaproxy.py index 85c7aeb7dcc..59071a2d6fa 100644 --- a/tests/pytests/integration/cli/test_salt_deltaproxy.py +++ b/tests/pytests/integration/cli/test_salt_deltaproxy.py @@ -51,7 +51,6 @@ def clear_proxy_minions(salt_master, proxy_minion_id): os.unlink(cachefile) -@pytest.mark.slow_test def test_exit_status_no_proxyid(salt_master, proxy_minion_id): """ Ensure correct exit status when --proxyid argument is missing. @@ -93,7 +92,6 @@ def test_exit_status_unknown_user(salt_master, proxy_minion_id): assert "The user is not available." in exc.value.process_result.stderr -@pytest.mark.slow_test def test_exit_status_unknown_argument(salt_master, proxy_minion_id): """ Ensure correct exit status when an unknown argument is passed to diff --git a/tests/pytests/unit/state/test_state_compiler.py b/tests/pytests/unit/state/test_state_compiler.py index bc96dc9e173..40933183089 100644 --- a/tests/pytests/unit/state/test_state_compiler.py +++ b/tests/pytests/unit/state/test_state_compiler.py @@ -38,7 +38,6 @@ def test_format_log_non_ascii_character(): salt.state.format_log(ret) -@pytest.mark.slow_test def test_render_error_on_invalid_requisite(minion_opts): """ Test that the state compiler correctly deliver a rendering diff --git a/tests/pytests/unit/state/test_state_format_slots.py b/tests/pytests/unit/state/test_state_format_slots.py index 1254994f34b..360f36c88d9 100644 --- a/tests/pytests/unit/state/test_state_format_slots.py +++ b/tests/pytests/unit/state/test_state_format_slots.py @@ -35,7 +35,6 @@ def test_format_slots_no_slots(state_obj): assert cdata == {"args": ["arg"], "kwargs": {"key": "val"}} -@pytest.mark.slow_test def test_format_slots_arg(state_obj): """ Test the format slots is calling a slot specified in args with corresponding arguments. @@ -51,7 +50,6 @@ def test_format_slots_arg(state_obj): assert cdata == {"args": ["fun_return"], "kwargs": {"key": "val"}} -@pytest.mark.slow_test def test_format_slots_dict_arg(state_obj): """ Test the format slots is calling a slot specified in dict arg. @@ -67,7 +65,6 @@ def test_format_slots_dict_arg(state_obj): assert cdata == {"args": [{"subarg": "fun_return"}], "kwargs": {"key": "val"}} -@pytest.mark.slow_test def test_format_slots_listdict_arg(state_obj): """ Test the format slots is calling a slot specified in list containing a dict. @@ -83,7 +80,6 @@ def test_format_slots_listdict_arg(state_obj): assert cdata == {"args": [[{"subarg": "fun_return"}]], "kwargs": {"key": "val"}} -@pytest.mark.slow_test def test_format_slots_liststr_arg(state_obj): """ Test the format slots is calling a slot specified in list containing a dict. @@ -99,7 +95,6 @@ def test_format_slots_liststr_arg(state_obj): assert cdata == {"args": [["fun_return"]], "kwargs": {"key": "val"}} -@pytest.mark.slow_test def test_format_slots_kwarg(state_obj): """ Test the format slots is calling a slot specified in kwargs with corresponding arguments. @@ -115,7 +110,6 @@ def test_format_slots_kwarg(state_obj): assert cdata == {"args": ["arg"], "kwargs": {"key": "fun_return"}} -@pytest.mark.slow_test def test_format_slots_multi(state_obj): """ Test the format slots is calling all slots with corresponding arguments when multiple slots @@ -155,7 +149,6 @@ def test_format_slots_multi(state_obj): } -@pytest.mark.slow_test def test_format_slots_malformed(state_obj): """ Test the format slots keeps malformed slots untouched. @@ -186,7 +179,6 @@ def test_format_slots_malformed(state_obj): assert cdata == sls_data -@pytest.mark.slow_test def test_slot_traverse_dict(state_obj): """ Test the slot parsing of dict response. @@ -203,7 +195,6 @@ def test_slot_traverse_dict(state_obj): assert cdata == {"args": ["arg"], "kwargs": {"key": "value1"}} -@pytest.mark.slow_test def test_slot_append(state_obj): """ Test the slot parsing of dict response. From 115f3f6d6c76cdf5d129060bf1875b07f583cb3b Mon Sep 17 00:00:00 2001 From: Charles McMarrow Date: Tue, 20 Jun 2023 16:38:10 -0500 Subject: [PATCH 5/9] Update conftest.py error msg --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 2a158df7b2a..c7c49f51e49 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -582,7 +582,7 @@ def pytest_runtest_setup(item): for group in ("core_test", "slow_test", "flaky_jail") ) if test_group_count > 1: - raise pytest.UsageError("Tests can only be in one test group.") + raise pytest.UsageError("Tests can only be in one test group. ('core_test', 'slow_test', 'flaky_jail')") if item.get_closest_marker("core_test"): if not item.config.getoption("--core-tests"): From ffa67b257ce5da9e5cf215434a4e35886a58e683 Mon Sep 17 00:00:00 2001 From: Charles McMarrow Date: Tue, 20 Jun 2023 17:06:25 -0500 Subject: [PATCH 6/9] Update conftest.py --- tests/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index c7c49f51e49..cda06ae995d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -582,7 +582,9 @@ def pytest_runtest_setup(item): for group in ("core_test", "slow_test", "flaky_jail") ) if test_group_count > 1: - raise pytest.UsageError("Tests can only be in one test group. ('core_test', 'slow_test', 'flaky_jail')") + raise pytest.UsageError( + "Tests can only be in one test group. ('core_test', 'slow_test', 'flaky_jail')" + ) if item.get_closest_marker("core_test"): if not item.config.getoption("--core-tests"): From 1f8dc3c510d8d40c4e9d9afd369db685202d5182 Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Tue, 27 Jun 2023 23:12:11 -0500 Subject: [PATCH 7/9] allow flaky to double group --- tests/conftest.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index cda06ae995d..a00dd3cd0fd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -578,37 +578,37 @@ def pytest_runtest_setup(item): item._skipped_by_mark = True pytest.skip(PRE_PYTEST_SKIP_REASON) test_group_count = sum( - bool(item.get_closest_marker(group)) - for group in ("core_test", "slow_test", "flaky_jail") + bool(item.get_closest_marker(group)) for group in ("core_test", "slow_test") ) - if test_group_count > 1: + if item.get_closest_marker("core_test") and item.get_closest_marker("slow_test"): raise pytest.UsageError( - "Tests can only be in one test group. ('core_test', 'slow_test', 'flaky_jail')" + "Tests can only be in one test group. ('core_test', 'slow_test')" ) - if item.get_closest_marker("core_test"): - if not item.config.getoption("--core-tests"): - raise pytest.skip.Exception( - "Core tests are disabled, pass '--core-tests' to enable them.", - _use_item_location=True, - ) - if item.get_closest_marker("slow_test"): - if not item.config.getoption("--slow-tests"): - raise pytest.skip.Exception( - "Slow tests are disabled, pass '--run-slow' to enable them.", - _use_item_location=True, - ) if item.get_closest_marker("flaky_jail"): if not item.config.getoption("--flaky-jail"): raise pytest.skip.Exception( "flaky jail tests are disabled, pass '--flaky-jail' to enable them.", _use_item_location=True, ) - if test_group_count == 0 and not item.config.getoption("--no-fast-tests"): - raise pytest.skip.Exception( - "Fast tests are disabled, dont pass '--no-fast-tests' to enable them.", - _use_item_location=True, - ) + else: + if item.get_closest_marker("core_test"): + if not item.config.getoption("--core-tests"): + raise pytest.skip.Exception( + "Core tests are disabled, pass '--core-tests' to enable them.", + _use_item_location=True, + ) + if item.get_closest_marker("slow_test"): + if not item.config.getoption("--slow-tests"): + raise pytest.skip.Exception( + "Slow tests are disabled, pass '--run-slow' to enable them.", + _use_item_location=True, + ) + if test_group_count == 0 and not item.config.getoption("--no-fast-tests"): + raise pytest.skip.Exception( + "Fast tests have been disabled by '--no-fast-tests'.", + _use_item_location=True, + ) requires_sshd_server_marker = item.get_closest_marker("requires_sshd_server") if requires_sshd_server_marker is not None: From a7b178beca324fc00e8ea380041447c7777a612f Mon Sep 17 00:00:00 2001 From: Charles McMarrow Date: Wed, 28 Jun 2023 11:13:45 -0500 Subject: [PATCH 8/9] Fix Fast Tests --- tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a00dd3cd0fd..7f8d171478d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -578,7 +578,7 @@ def pytest_runtest_setup(item): item._skipped_by_mark = True pytest.skip(PRE_PYTEST_SKIP_REASON) test_group_count = sum( - bool(item.get_closest_marker(group)) for group in ("core_test", "slow_test") + bool(item.get_closest_marker(group)) for group in ("core_test", "slow_test", "flaky_jail") ) if item.get_closest_marker("core_test") and item.get_closest_marker("slow_test"): raise pytest.UsageError( @@ -604,7 +604,7 @@ def pytest_runtest_setup(item): "Slow tests are disabled, pass '--run-slow' to enable them.", _use_item_location=True, ) - if test_group_count == 0 and not item.config.getoption("--no-fast-tests"): + if test_group_count == 0 and item.config.getoption("--no-fast-tests"): raise pytest.skip.Exception( "Fast tests have been disabled by '--no-fast-tests'.", _use_item_location=True, From 8869972f075ca409e96a6fd4369c1447866c168d Mon Sep 17 00:00:00 2001 From: Charles McMarrow Date: Wed, 28 Jun 2023 14:01:54 -0500 Subject: [PATCH 9/9] fix pre --- tests/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 7f8d171478d..1bb55aabee3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -578,7 +578,8 @@ def pytest_runtest_setup(item): item._skipped_by_mark = True pytest.skip(PRE_PYTEST_SKIP_REASON) test_group_count = sum( - bool(item.get_closest_marker(group)) for group in ("core_test", "slow_test", "flaky_jail") + bool(item.get_closest_marker(group)) + for group in ("core_test", "slow_test", "flaky_jail") ) if item.get_closest_marker("core_test") and item.get_closest_marker("slow_test"): raise pytest.UsageError(