Open cmutel opened 1 year ago
Came here to create this exactly issue, the issue is contained here:
# bw2data/project.py
projects = ProjectManager()
# bw2data/tests.py
from .project import projects
@wrapt.decorator
def bw2test(wrapped, instance, args, kwargs):
# …
projects.change_base_directories(
base_dir=tempdir, base_logs_dir=tempdir, project_name=project_name, update=False
)
projects._is_temp_dir = True
# …
Since projects
is a singleton, changing its state in the wrapper changes it for everyone. As a rule of thumb, always restore mocked or patched objects.
Probably the best way going forward is to refactor testing and use pytest's fixtures.
Maybe this isn't the issue you tried to describe, but at least related.
All classes should create projects in temporary directories, but this isn't happening for some reason.