diff --git a/src/borg/testsuite/archiver/config_cmd.py b/src/borg/testsuite/archiver/config_cmd.py index f76234beac..fa89df241d 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 4bea39f901..72e8bc97d6 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 1935bde69a..ef00e007e9 100644 --- a/src/borg/testsuite/archiver/key_cmds.py +++ b/src/borg/testsuite/archiver/key_cmds.py @@ -6,7 +6,7 @@ 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 48c9dc1622..b027ca1a85 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 e18eee4609..99dc6f2a7c 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 fc7f8d1b94..b21a73fc8e 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):