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

Rewrite config mocking #1447

Merged
merged 5 commits into from
May 16, 2023
Merged

Rewrite config mocking #1447

merged 5 commits into from
May 16, 2023

Conversation

vkbo
Copy link
Owner

@vkbo vkbo commented May 16, 2023

Summary:

This PR rewrites how the global CONFIG object is handled during testing. It is no longer mocked and replaced by a test config object, but is instead reset before each test is run. This means there is no need to assign the global CONFIG object to a class attribute at the initialisation of a class so it can be overridden in the tests. Since the CONFIG object is created immediately on first import, it is very tricky to mock.

With this change, CONFIG is accessed directly wherever access to the user's config settings are needed. This should also be marginally faster, as the object is no longer stored in a class dictionary, which adds a bit of overhead when accessing it.

Related Issue(s):

Reviewer's Checklist:

  • The header of all files contain a reference to the repository license
  • The overall test coverage is increased or remains the same as before
  • All tests are passing
  • All flake8 checks are passing and the style guide is followed
  • Documentation (as docstrings) is complete and understandable
  • Only files that have been actively changed are committed

@vkbo vkbo added this to the Release 2.1 Beta 1 milestone May 16, 2023
@vkbo vkbo merged commit 03a19a8 into dev May 16, 2023
@vkbo vkbo deleted the fix_config_mock branch May 16, 2023 21:29
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