Skip to content

get_state() causing problems in tests #75

Description

@pederhan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtestsAutomated tests

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions