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

get_state() causing problems in tests #75

Open
pederhan opened this issue Aug 7, 2023 · 0 comments
Open

get_state() causing problems in tests #75

pederhan opened this issue Aug 7, 2023 · 0 comments
Labels
bug Something isn't working tests Automated tests

Comments

@pederhan
Copy link
Member

pederhan commented Aug 7, 2023

Adding state.get_state and then calling it at the top of each module that needs access to the state is a really bad idea I think? Even though it reduces a lot of state = get_state() calls inside functions, this sort of top-level instantiation of global objects just irks me, and it has proven to be a very painful when testing due to the tests mutating the State object.

I'm having a hard time wrapping my head around the problem completely, but it seems like even when using State as a singleton, the modules that have already instantiated State via get_state() could conceivably have a different version of the State object due to the shenanigans we do when resetting the state in tests. Maybe we should just do state = get_state() where it is required?

This is a really poorly explained issue for now... 4 hours of fixing broken tests due to mutation of global objects has fried my brain.

@pederhan pederhan added bug Something isn't working tests Automated tests labels Aug 7, 2023
@pederhan pederhan added this to Harbor Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tests Automated tests
Projects
None yet
Development

No branches or pull requests

1 participant