Skip to content

Commit

Permalink
Merge pull request #64574 from s0undt3ch/hotfix/merge-forward
Browse files Browse the repository at this point in the history
[master] Merge 3006.x into master
  • Loading branch information
Megan Wilhite authored Jun 29, 2023
2 parents c463c94 + 2e96267 commit 2d02017
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 127 deletions.
5 changes: 5 additions & 0 deletions changelog/64565.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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
42 changes: 23 additions & 19 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,33 +577,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")
)
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')"
)

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 (
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"):
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 item.config.getoption("--no-fast-tests"):
raise pytest.skip.Exception(
"Fast tests are disabled, dont pass '--no-fast-tests' to enable them.",
"Fast tests have been disabled by '--no-fast-tests'.",
_use_item_location=True,
)

Expand Down
13 changes: 6 additions & 7 deletions tests/pytests/functional/modules/state/requisites/test_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -370,29 +369,29 @@ def test_issue_30161_unless_and_onlyif_together(state, state_tree, tmp_path):
# then the unless state run bailed out after the first unless command succeeded,
# which is the bug we're regression testing for.
_expected = {
"file_|-unless_false_onlyif_false_|-{}_|-managed".format(test_txt_path): {
f"file_|-unless_false_onlyif_false_|-{test_txt_path}_|-managed": {
"comment": "onlyif condition is false\nunless condition is false",
"name": "{}".format(test_txt_path),
"name": f"{test_txt_path}",
"skip_watch": True,
"changes": {},
"result": True,
},
"file_|-unless_false_onlyif_true_|-{}_|-managed".format(test_txt_path): {
f"file_|-unless_false_onlyif_true_|-{test_txt_path}_|-managed": {
"comment": "Empty file",
"name": str(test_txt_path),
"start_time": "18:10:20.341753",
"result": True,
"changes": {"new": "file {} created".format(test_txt_path)},
"changes": {"new": f"file {test_txt_path} created"},
},
"file_|-unless_true_onlyif_false_|-{}_|-managed".format(test_txt_path): {
f"file_|-unless_true_onlyif_false_|-{test_txt_path}_|-managed": {
"comment": "onlyif condition is false\nunless condition is true",
"name": str(test_txt_path),
"start_time": "18:10:22.936446",
"skip_watch": True,
"changes": {},
"result": True,
},
"file_|-unless_true_onlyif_true_|-{}_|-managed".format(test_txt_path): {
f"file_|-unless_true_onlyif_true_|-{test_txt_path}_|-managed": {
"comment": "onlyif condition is true\nunless condition is true",
"name": str(test_txt_path),
"skip_watch": True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -610,7 +609,7 @@ def test_parallel_state_with_requires(state, state_tree):
assert (end_time - start_time) < 30

for item in range(1, 10):
_id = "cmd_|-blah-{}_|-sleep 2_|-run".format(item)
_id = f"cmd_|-blah-{item}_|-sleep 2_|-run"
assert "__parallel__" in ret[_id]


Expand Down
33 changes: 16 additions & 17 deletions tests/pytests/functional/modules/state/requisites/test_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -114,51 +113,51 @@ def test_requisites_watch_any(state, state_tree):
cmd_true=cmd_true, cmd_false=cmd_false
)
expected_result = {
"cmd_|-A_|-{}_|-wait".format(cmd_true): {
f"cmd_|-A_|-{cmd_true}_|-wait": {
"__run_num__": 4,
"comment": 'Command "{}" run'.format(cmd_true),
"comment": f'Command "{cmd_true}" run',
"result": True,
"changes": True,
},
"cmd_|-B_|-{}_|-run".format(cmd_true): {
f"cmd_|-B_|-{cmd_true}_|-run": {
"__run_num__": 0,
"comment": 'Command "{}" run'.format(cmd_true),
"comment": f'Command "{cmd_true}" run',
"result": True,
"changes": True,
},
"cmd_|-C_|-{}_|-run".format(cmd_false): {
f"cmd_|-C_|-{cmd_false}_|-run": {
"__run_num__": 1,
"comment": 'Command "{}" run'.format(cmd_false),
"comment": f'Command "{cmd_false}" run',
"result": False,
"changes": True,
},
"cmd_|-D_|-{}_|-run".format(cmd_true): {
f"cmd_|-D_|-{cmd_true}_|-run": {
"__run_num__": 2,
"comment": 'Command "{}" run'.format(cmd_true),
"comment": f'Command "{cmd_true}" run',
"result": True,
"changes": True,
},
"cmd_|-E_|-{}_|-wait".format(cmd_true): {
f"cmd_|-E_|-{cmd_true}_|-wait": {
"__run_num__": 9,
"comment": 'Command "{}" run'.format(cmd_true),
"comment": f'Command "{cmd_true}" run',
"result": True,
"changes": True,
},
"cmd_|-F_|-{}_|-run".format(cmd_true): {
f"cmd_|-F_|-{cmd_true}_|-run": {
"__run_num__": 5,
"comment": 'Command "{}" run'.format(cmd_true),
"comment": f'Command "{cmd_true}" run',
"result": True,
"changes": True,
},
"cmd_|-G_|-{}_|-run".format(cmd_false): {
f"cmd_|-G_|-{cmd_false}_|-run": {
"__run_num__": 6,
"comment": 'Command "{}" run'.format(cmd_false),
"comment": f'Command "{cmd_false}" run',
"result": False,
"changes": True,
},
"cmd_|-H_|-{}_|-run".format(cmd_false): {
f"cmd_|-H_|-{cmd_false}_|-run": {
"__run_num__": 7,
"comment": 'Command "{}" run'.format(cmd_false),
"comment": f'Command "{cmd_false}" run',
"result": False,
"changes": True,
},
Expand Down
10 changes: 2 additions & 8 deletions tests/pytests/functional/modules/state/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -800,7 +798,6 @@ def create_testfile(testfile1, testfile2):
@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
Expand Down Expand Up @@ -849,7 +846,6 @@ def create_testfile(testfile1, testfile2):
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
Expand Down Expand Up @@ -908,10 +904,8 @@ def test_parallel_state_with_long_tag(state, state_tree):
)

comments = sorted(x.comment for x in ret)
expected = sorted(
'Command "{}" run'.format(x) for x in (short_command, long_command)
)
assert comments == expected, "{} != {}".format(comments, expected)
expected = sorted(f'Command "{x}" run' for x in (short_command, long_command))
assert comments == expected, f"{comments} != {expected}"


@pytest.mark.skip_on_darwin(reason="Test is broken on macosx")
Expand Down
3 changes: 1 addition & 2 deletions tests/pytests/integration/cli/test_salt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -156,7 +155,7 @@ def test_interrupt_on_long_running_job(salt_cli, salt_master, salt_minion):
cmdline = [
sys.executable,
salt_cli.get_script_path(),
"--config-dir={}".format(salt_master.config_dir),
f"--config-dir={salt_master.config_dir}",
salt_minion.id,
"test.sleep",
"30",
Expand Down
1 change: 0 additions & 1 deletion tests/pytests/integration/cli/test_salt_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
26 changes: 11 additions & 15 deletions tests/pytests/integration/cli/test_salt_deltaproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@ def clear_proxy_minions(salt_master, proxy_minion_id):
for proxy in [proxy_minion_id, "dummy_proxy_one", "dummy_proxy_two"]:
pytest.helpers.remove_stale_minion_key(salt_master, proxy)

cachefile = os.path.join(
salt_master.config["cachedir"], "{}.cache".format(proxy)
)
cachefile = os.path.join(salt_master.config["cachedir"], f"{proxy}.cache")
if os.path.exists(cachefile):
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.
Expand Down Expand Up @@ -93,7 +90,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
Expand Down Expand Up @@ -183,11 +179,11 @@ def test_exit_status_correct_usage(
"controlproxy.sls", controlproxy_pillar_file
)
dummy_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
"{}.sls".format(proxy_one),
f"{proxy_one}.sls",
dummy_proxy_one_pillar_file,
)
dummy_proxy_two_tempfile = salt_master.pillar_tree.base.temp_file(
"{}.sls".format(proxy_two),
f"{proxy_two}.sls",
dummy_proxy_two_pillar_file,
)
with top_tempfile, controlproxy_tempfile, dummy_proxy_one_tempfile, dummy_proxy_two_tempfile:
Expand Down Expand Up @@ -290,7 +286,7 @@ def test_missing_pillar_file(
"controlproxy.sls", controlproxy_pillar_file
)
dummy_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
"{}.sls".format(proxy_one),
f"{proxy_one}.sls",
dummy_proxy_one_pillar_file,
)
with top_tempfile, controlproxy_tempfile, dummy_proxy_one_tempfile:
Expand Down Expand Up @@ -408,14 +404,14 @@ def test_invalid_connection(
"controlproxy.sls", controlproxy_pillar_file
)
dummy_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
"{}.sls".format(proxy_one),
f"{proxy_one}.sls",
dummy_proxy_one_pillar_file,
)
broken_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
"{}.sls".format(broken_proxy_one), broken_proxy_one_pillar_file
f"{broken_proxy_one}.sls", broken_proxy_one_pillar_file
)
broken_proxy_two_tempfile = salt_master.pillar_tree.base.temp_file(
"{}.sls".format(broken_proxy_two), broken_proxy_two_pillar_file
f"{broken_proxy_two}.sls", broken_proxy_two_pillar_file
)
with top_tempfile, controlproxy_tempfile, dummy_proxy_one_tempfile, broken_proxy_one_tempfile, broken_proxy_two_tempfile:
factory = salt_master.salt_proxy_minion_daemon(
Expand Down Expand Up @@ -536,11 +532,11 @@ def ping():
"controlproxy.sls", controlproxy_pillar_file
)
dummy_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
"{}.sls".format(proxy_one),
f"{proxy_one}.sls",
dummy_proxy_one_pillar_file,
)
dummy_proxy_two_tempfile = salt_master.pillar_tree.base.temp_file(
"{}.sls".format(proxy_two),
f"{proxy_two}.sls",
dummy_proxy_two_pillar_file,
)

Expand Down Expand Up @@ -670,11 +666,11 @@ def ping():
"controlproxy.sls", controlproxy_pillar_file
)
dummy_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
"{}.sls".format(proxy_one),
f"{proxy_one}.sls",
dummy_proxy_one_pillar_file,
)
dummy_proxy_two_tempfile = salt_master.pillar_tree.base.temp_file(
"{}.sls".format(proxy_two),
f"{proxy_two}.sls",
dummy_proxy_two_pillar_file,
)

Expand Down
Loading

0 comments on commit 2d02017

Please sign in to comment.