-
Notifications
You must be signed in to change notification settings - Fork 229
Description
Describe the bug
There seem to be some issues with combining some AiiDA profile test fixtures with other session-scoped fixtures that return nodes. Using a function-scoped fixture like aiida_profile_tmp
breaks tests down the line with a ClosedStorage
error.
Steps to reproduce
Add a new file to the root of your test suite with the following content:
from aiida import orm
import pytest
@pytest.fixture(scope='session')
def node():
return orm.Int(1).store()
def test_break_storage(node):
node.value
def test_use_tmp_profile(aiida_profile_tmp):
"""I break the test below!"""
def test_break_storage_post(node):
node.value
And run it. You should see that test_break_storage
passes but test_break_storage_post
fails with a ClosedStorage
error.
Expected behavior
I was thinking that the aiida_profile_tmp
gives me a nice isolated profile I can use in case I want to run tests that might overlap with others and cause breaking behaviour. But perhaps I'm wrong? Maybe using fixtures that return nodes directly instead of functions that create them are a bad idea.
Your environment
- Operating system [e.g. Linux]: macOS
- Python version [e.g. 3.7.1]: 3.10.18
- aiida-core version [e.g. 1.2.1]:
main
- commit 313f342
Additional context
I ran into this issue when trying to isolate the CLI tests in aiidateam/aiida-quantumespresso@0e1ae24. The offending fixture is the pseudo_family
one, which creates a group and returns it:
Interestingly, removing the autouse
there1 fixes the issue, even if the fixture is session scoped. pytest
is a never-ending source of puzzles to solve. ^^
Footnotes
-
which I'm removing in any case, not sure why it's there, seems like a good way to create nasty bugs ↩