Fix error bubbling in outdated test
Marco Ricci

Marco Ricci commited on 2024-08-16 16:19:56
Zeige 2 geänderte Dateien mit 6 Einfügungen und 3 Löschungen.


In
`tests.test_derivepassphrase_cli:test_230a_config_directory_not_a_file`,
we assumed that a `FileExistsError` while storing the configuration file
would bubble all the way up to the test harness.  This isn't the case
anymore, because of a1763e8b5dedbf123856a79ddb0e8395cddd6f88 and
5c6045e10ca9c8b56432711dec5efb98b5892d55... but we actually forgot to
update the call to use the new wrapper from
5c6045e10ca9c8b56432711dec5efb98b5892d55.
... ...
@@ -1081,7 +1081,7 @@ def derivepassphrase(
1081 1081
             assert _types.is_vault_config(
1082 1082
                 configuration
1083 1083
             ), f'invalid vault configuration: {configuration!r}'
1084
-            _save_config(configuration)
1084
+            put_config(configuration)
1085 1085
         else:
1086 1086
             if not service:
1087 1087
                 msg = 'SERVICE is required'
... ...
@@ -1094,13 +1094,16 @@ contents go here
1094 1094
                 return _save_config(*args, **kwargs)
1095 1095
 
1096 1096
             monkeypatch.setattr(cli, '_save_config', obstruct_config_saving)
1097
-            with pytest.raises(FileExistsError):
1098
-                runner.invoke(
1097
+            result = runner.invoke(
1099 1098
                 cli.derivepassphrase,
1100 1099
                 ['--config', '-p'],
1101 1100
                 catch_exceptions=False,
1102 1101
                 input='abc\n',
1103 1102
             )
1103
+            assert result.exit_code != 0, 'program unexpectedly succeeded?!'
1104
+            assert (
1105
+                b'Cannot store config' in result.stderr_bytes
1106
+            ), 'program unexpectedly failed?!'
1104 1107
 
1105 1108
 
1106 1109
 class TestCLIUtils:
1107 1110