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

refactor: make config monkeypatchable #531

Closed

Conversation

CarliJoy
Copy link
Contributor

@CarliJoy CarliJoy commented Apr 8, 2024

I am using testcontainers within a library that provides some pytest-fixtures.
In order for this to work I have change some settings.

As I can not guarantee that that my lib is imported before testcontainers I need to monkeypatch the settings.
This is much easier if I only need to monkeypatch the config file and not all modules that use configurations.

I would argue that for a potential library as this, this is a better design.

Also one can easier see that the given UPERCASE variable is not a constant but rather a setting.

@alexanderankin
Copy link
Member

what if we gave you the red carpet treatment and actually made an API for this, like

https://github.com/testcontainers/testcontainers-python/compare/editable_config?expand=1

alexanderankin added a commit that referenced this pull request Apr 8, 2024
see #531:

I am using testcontainers within a library that provides some
pytest-fixtures.
In order for this to work I have change some settings.

As I can not guarantee that that my lib is imported before
testcontainers I need to monkeypatch the settings.
This is much easier if I only need to monkeypatch the config file and
not all modules that use configurations.

I would argue that for a potential library as this, this is a better
design.

Also one can easier see that the given UPERCASE variable is not a
constant but rather a setting.

Co-authored-by: Carli* Freudenberg <[email protected]>
@alexanderankin
Copy link
Member

thanks for the idea - i gave you credit in my merge commit in #532, going to close this for now

mloesch pushed a commit to mloesch/testcontainers-python that referenced this pull request Apr 8, 2024
…ners#532)

see testcontainers#531:

I am using testcontainers within a library that provides some
pytest-fixtures.
In order for this to work I have change some settings.

As I can not guarantee that that my lib is imported before
testcontainers I need to monkeypatch the settings.
This is much easier if I only need to monkeypatch the config file and
not all modules that use configurations.

I would argue that for a potential library as this, this is a better
design.

Also one can easier see that the given UPERCASE variable is not a
constant but rather a setting.

Co-authored-by: Carli* Freudenberg <[email protected]>
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.

2 participants