Skip to content

Get rid of ResourceWarning of pytest #551

@unkcpz

Description

@unkcpz

In #509, the warnings are shown as errors, and will popped up if run with pytest -s.

Here is one that we don't know how to get rid of:

Traceback (most recent call last):
  File "/home/jyu/micromamba/envs/aiidalab-dev/lib/python3.9/site-packages/_pytest/unraisableexception.py", line 59, in __exit__
    del self.unraisable
ResourceWarning: unclosed file <_io.BufferedReader name=6>
Exception ignored in: <_io.FileIO name=8 mode='rb' closefd=True>
Traceback (most recent call last):
  File "/home/jyu/micromamba/envs/aiidalab-dev/lib/python3.9/site-packages/_pytest/unraisableexception.py", line 59, in __exit__
    del self.unraisable
ResourceWarning: unclosed file <_io.BufferedReader name=8>

I did a close look and narrow it down to aiida.manage.tests.pytest_fixtures::aiida_profile. It must be someway to elegantly close the file when the test session closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedThis issue/PR is blocked by another issue/PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions