Make this test resistant to environments where the password envvar exists

pull/1576/head
David Núñez 2020-01-19 01:55:25 +01:00
parent d5dd4cff68
commit 637a750b94
1 changed files with 7 additions and 3 deletions

View File

@ -17,7 +17,9 @@ def test_missing_configuration_file(default_filepath_mock, click_runner):
assert "run: 'nucypher alice init'" in result.output
def test_initialize_alice_defaults(click_runner, mocker, custom_filepath):
def test_initialize_alice_defaults(click_runner, mocker, custom_filepath, monkeypatch):
monkeypatch.delenv("NUCYPHER_KEYRING_PASSWORD", raising=False)
# Mock out filesystem writes
mocker.patch.object(AliceConfiguration, 'initialize', autospec=True)
mocker.patch.object(AliceConfiguration, 'to_configuration_file', autospec=True)
@ -40,7 +42,8 @@ def test_initialize_alice_defaults(click_runner, mocker, custom_filepath):
assert 'Repeat for confirmation:' in result.output, 'User was not prompted to confirm password'
def test_alice_control_starts_with_mocked_keyring(click_runner, mocker):
def test_alice_control_starts_with_mocked_keyring(click_runner, mocker, monkeypatch):
monkeypatch.delenv("NUCYPHER_KEYRING_PASSWORD", raising=False)
class MockKeyring:
is_unlocked = False
@ -60,7 +63,8 @@ def test_alice_control_starts_with_mocked_keyring(click_runner, mocker):
assert result.exit_code == 0, result.exception
def test_initialize_alice_with_custom_configuration_root(custom_filepath, click_runner):
def test_initialize_alice_with_custom_configuration_root(custom_filepath, click_runner, monkeypatch):
monkeypatch.delenv("NUCYPHER_KEYRING_PASSWORD", raising=False)
# Use a custom local filepath for configuration
init_args = ('alice', 'init',