Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace memory_keyring with tmp_keyring #264

Merged
merged 5 commits into from
Feb 28, 2023
Merged

Replace memory_keyring with tmp_keyring #264

merged 5 commits into from
Feb 28, 2023

Conversation

mih
Copy link
Member

@mih mih commented Feb 28, 2023

The former was limited to within process operations. However, we do need to be able to communicate credentials to child processes, such as (special) remotes.

The approach for the tmp_keyring fixture is to replace the storage file for the plaintext keyring with a random file, and then communicate the path via the DATALAD_TESTS_TMP_KEYRING_PATH envvar.

An additional patch recognizes this variable and alters a keyring in a child process accordingly.

The former was limited to within process operations. However, we do need
to be able to communicate credentials to child processes, such as
(special) remotes.

The approach for the `tmp_keyring` fixture is to replace the storage
file for the plaintext keyring with a random file, and then communicate
the path via the DATALAD_TESTS_TMP_KEYRING_PATH envvar.

An additional patch recognizes this variable and alters a keyring
in a child process accordingly.
Much cleaner. Both in terms of style and in terms of actually isolating
the side-effect of individual tests from each other.

Requesting the `credman` fixture automatically implies global config
isolation and keyring isolation.
The `credman` fixture is a superior approach.
Pytest docs recommend against importing them. Instead, they should be
declared as plugins via something like

```
pytest_plugins = "datalad_next.tests.fixtures"
```

https://docs.pytest.org/en/latest/how-to/fixtures.html#using-fixtures-from-other-projects
@mih mih merged commit 9a0414f into datalad:main Feb 28, 2023
@mih mih deleted the testsetup branch February 28, 2023 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant