diff options
author | Thomas Waldmann <tw@waldmann-edv.de> | 2024-07-20 00:39:37 +0200 |
---|---|---|
committer | Thomas Waldmann <tw@waldmann-edv.de> | 2024-07-20 00:39:37 +0200 |
commit | 7aabe8204cc0570b47e14b251054f9882edfb7f6 (patch) | |
tree | 9b56606580b12fb9392ebcc095f972b2d412646b | |
parent | edfca29b9704c20ff080753ec38ccef0509fa6f3 (diff) |
fix binary_archiver tests for modern exit codes2.0.0b9
-rw-r--r-- | src/borg/testsuite/archiver/config_cmd.py | 3 | ||||
-rw-r--r-- | src/borg/testsuite/archiver/create_cmd.py | 10 | ||||
-rw-r--r-- | src/borg/testsuite/archiver/key_cmds.py | 17 | ||||
-rw-r--r-- | src/borg/testsuite/archiver/rcreate_cmd.py | 3 | ||||
-rw-r--r-- | src/borg/testsuite/archiver/rdelete_cmd.py | 3 | ||||
-rw-r--r-- | src/borg/testsuite/archiver/recreate_cmd.py | 3 |
6 files changed, 27 insertions, 12 deletions
diff --git a/src/borg/testsuite/archiver/config_cmd.py b/src/borg/testsuite/archiver/config_cmd.py index f76234bea..fa89df241 100644 --- a/src/borg/testsuite/archiver/config_cmd.py +++ b/src/borg/testsuite/archiver/config_cmd.py @@ -52,7 +52,8 @@ def test_config(archivers, request): cmd(archiver, "config", "--list", "--delete", exit_code=2) if archiver.FORK_DEFAULT: - cmd(archiver, "config", exit_code=2) + expected_ec = CommandError().exit_code + cmd(archiver, "config", exit_code=expected_ec) else: with pytest.raises(CommandError): cmd(archiver, "config") diff --git a/src/borg/testsuite/archiver/create_cmd.py b/src/borg/testsuite/archiver/create_cmd.py index 4bea39f90..72e8bc97d 100644 --- a/src/borg/testsuite/archiver/create_cmd.py +++ b/src/borg/testsuite/archiver/create_cmd.py @@ -366,7 +366,10 @@ def test_create_content_from_command_with_failed_command(archivers, request): archiver = request.getfixturevalue(archivers) cmd(archiver, "rcreate", RK_ENCRYPTION) if archiver.FORK_DEFAULT: - output = cmd(archiver, "create", "--content-from-command", "test", "--", "sh", "-c", "exit 73;", exit_code=2) + expected_ec = CommandError().exit_code + output = cmd( + archiver, "create", "--content-from-command", "test", "--", "sh", "-c", "exit 73;", exit_code=expected_ec + ) assert output.endswith("Command 'sh' exited with status 73" + os.linesep) else: with pytest.raises(CommandError): @@ -418,7 +421,10 @@ def test_create_paths_from_command_with_failed_command(archivers, request): archiver = request.getfixturevalue(archivers) cmd(archiver, "rcreate", RK_ENCRYPTION) if archiver.FORK_DEFAULT: - output = cmd(archiver, "create", "--paths-from-command", "test", "--", "sh", "-c", "exit 73;", exit_code=2) + expected_ec = CommandError().exit_code + output = cmd( + archiver, "create", "--paths-from-command", "test", "--", "sh", "-c", "exit 73;", exit_code=expected_ec + ) assert output.endswith("Command 'sh' exited with status 73" + os.linesep) else: with pytest.raises(CommandError): diff --git a/src/borg/testsuite/archiver/key_cmds.py b/src/borg/testsuite/archiver/key_cmds.py index 1935bde69..ef00e007e 100644 --- a/src/borg/testsuite/archiver/key_cmds.py +++ b/src/borg/testsuite/archiver/key_cmds.py @@ -6,7 +6,7 @@ import pytest from ...constants import * # NOQA from ...crypto.key import AESOCBRepoKey, AESOCBKeyfileKey, CHPOKeyfileKey, Passphrase from ...crypto.keymanager import RepoIdMismatch, NotABorgKeyFile -from ...helpers import EXIT_ERROR, CommandError +from ...helpers import CommandError from ...helpers import bin_to_hex, hex_to_bin from ...helpers import msgpack from ...repository import Repository @@ -171,7 +171,8 @@ def test_key_export_directory(archivers, request): os.mkdir(export_directory) cmd(archiver, "rcreate", RK_ENCRYPTION) if archiver.FORK_DEFAULT: - cmd(archiver, "key", "export", export_directory, exit_code=EXIT_ERROR) + expected_ec = CommandError().exit_code + cmd(archiver, "key", "export", export_directory, exit_code=expected_ec) else: with pytest.raises(CommandError): cmd(archiver, "key", "export", export_directory) @@ -183,7 +184,8 @@ def test_key_export_qr_directory(archivers, request): os.mkdir(export_directory) cmd(archiver, "rcreate", RK_ENCRYPTION) if archiver.FORK_DEFAULT: - cmd(archiver, "key", "export", "--qr-html", export_directory, exit_code=EXIT_ERROR) + expected_ec = CommandError().exit_code + cmd(archiver, "key", "export", "--qr-html", export_directory, exit_code=expected_ec) else: with pytest.raises(CommandError): cmd(archiver, "key", "export", "--qr-html", export_directory) @@ -194,7 +196,8 @@ def test_key_import_errors(archivers, request): export_file = archiver.output_path + "/exported" cmd(archiver, "rcreate", KF_ENCRYPTION) if archiver.FORK_DEFAULT: - cmd(archiver, "key", "import", export_file, exit_code=EXIT_ERROR) + expected_ec = CommandError().exit_code + cmd(archiver, "key", "import", export_file, exit_code=expected_ec) else: with pytest.raises(CommandError): cmd(archiver, "key", "import", export_file) @@ -203,7 +206,8 @@ def test_key_import_errors(archivers, request): fd.write("something not a key\n") if archiver.FORK_DEFAULT: - cmd(archiver, "key", "import", export_file, exit_code=2) + expected_ec = NotABorgKeyFile().exit_code + cmd(archiver, "key", "import", export_file, exit_code=expected_ec) else: with pytest.raises(NotABorgKeyFile): cmd(archiver, "key", "import", export_file) @@ -212,7 +216,8 @@ def test_key_import_errors(archivers, request): fd.write("BORG_KEY a0a0a0\n") if archiver.FORK_DEFAULT: - cmd(archiver, "key", "import", export_file, exit_code=2) + expected_ec = RepoIdMismatch().exit_code + cmd(archiver, "key", "import", export_file, exit_code=expected_ec) else: with pytest.raises(RepoIdMismatch): cmd(archiver, "key", "import", export_file) diff --git a/src/borg/testsuite/archiver/rcreate_cmd.py b/src/borg/testsuite/archiver/rcreate_cmd.py index 48c9dc162..b027ca1a8 100644 --- a/src/borg/testsuite/archiver/rcreate_cmd.py +++ b/src/borg/testsuite/archiver/rcreate_cmd.py @@ -56,7 +56,8 @@ def test_rcreate_nested_repositories(archivers, request): cmd(archiver, "rcreate", RK_ENCRYPTION) archiver.repository_location += "/nested" if archiver.FORK_DEFAULT: - cmd(archiver, "rcreate", RK_ENCRYPTION, exit_code=2) + expected_ec = Repository.AlreadyExists().exit_code + cmd(archiver, "rcreate", RK_ENCRYPTION, exit_code=expected_ec) else: with pytest.raises(Repository.AlreadyExists): cmd(archiver, "rcreate", RK_ENCRYPTION) diff --git a/src/borg/testsuite/archiver/rdelete_cmd.py b/src/borg/testsuite/archiver/rdelete_cmd.py index e18eee460..99dc6f2a7 100644 --- a/src/borg/testsuite/archiver/rdelete_cmd.py +++ b/src/borg/testsuite/archiver/rdelete_cmd.py @@ -18,7 +18,8 @@ def test_delete_repo(archivers, request): cmd(archiver, "create", "test.2", "input") os.environ["BORG_DELETE_I_KNOW_WHAT_I_AM_DOING"] = "no" if archiver.FORK_DEFAULT: - cmd(archiver, "rdelete", exit_code=2) + expected_ec = CancelledByUser().exit_code + cmd(archiver, "rdelete", exit_code=expected_ec) else: with pytest.raises(CancelledByUser): cmd(archiver, "rdelete") diff --git a/src/borg/testsuite/archiver/recreate_cmd.py b/src/borg/testsuite/archiver/recreate_cmd.py index fc7f8d1b9..b21a73fc8 100644 --- a/src/borg/testsuite/archiver/recreate_cmd.py +++ b/src/borg/testsuite/archiver/recreate_cmd.py @@ -84,7 +84,8 @@ def test_recreate_target_rc(archivers, request): archiver = request.getfixturevalue(archivers) cmd(archiver, "rcreate", RK_ENCRYPTION) if archiver.FORK_DEFAULT: - output = cmd(archiver, "recreate", "--target=asdf", exit_code=2) + expected_ec = CommandError().exit_code + output = cmd(archiver, "recreate", "--target=asdf", exit_code=expected_ec) assert "Need to specify single archive" in output else: with pytest.raises(CommandError): |