You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, many of the fixtures in AiiDA, such as aiida_localhost (here) are function-scoped (which is the pytest default). It would be nice to have a way to also use them at different scopes, e.g., class-scoped, for expensive setup-operations that should only be carried out once for a test class, for example.
One idea to allow this, originally brought up by @agoscinski on Slack, is to put the functionality currently contained in the fixtures into utility functions, which are then used by differently scoped fixtures, like:
# the logic that was in aiida_localhost is moved heredefutils_aiida_localhost(...):
...
# new fixture only class scope@pytest.fixture(scope="class")defaiida_localhost_class(...):
utils_aiida_localhost(...)
# original fixture@pytest.fixture(scope="function") # Currently the default, even without explicitly specifying `scope="function"`defaiida_localhost(...): # or `aiida_localhost_function`, but backwards-incompatibleutils_aiida_localhost(...)
To achieve this, a few other changes might also be necessary, as, e.g., tmp_path provided by pytest is also function scoped, so cannot be used in a class- or session-scoped fixture (instead, pytest provides the session-scoped tmp_path_factory fixture).
The text was updated successfully, but these errors were encountered:
Currently, many of the fixtures in AiiDA, such as
aiida_localhost
(here) are function-scoped (which is thepytest
default). It would be nice to have a way to also use them at different scopes, e.g., class-scoped, for expensive setup-operations that should only be carried out once for a test class, for example.One idea to allow this, originally brought up by @agoscinski on Slack, is to put the functionality currently contained in the fixtures into utility functions, which are then used by differently scoped fixtures, like:
To achieve this, a few other changes might also be necessary, as, e.g.,
tmp_path
provided by pytest is also function scoped, so cannot be used in a class- or session-scoped fixture (instead, pytest provides the session-scopedtmp_path_factory
fixture).The text was updated successfully, but these errors were encountered: