aiidalab / aiidalab-widgets-base

Reusable widgets for AiiDAlab applications
MIT License
6 stars 17 forks source link

Get rid of ResourceWarning of pytest #551

Open unkcpz opened 5 months ago

unkcpz commented 5 months ago

In https://github.com/aiidalab/aiidalab-widgets-base/pull/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.

danielhollas commented 5 months ago

@unkcpz it might be good to open this issue in the aiida-core repo since that's where it should be fixed imo (or at least we should try to fix it there first). Thank for digging into this, this was an extremely frustrating issue when I was getting rid of all the other warnings.

unkcpz commented 5 months ago

Sure, I asked Sebastiaan in https://github.com/aiidateam/aiida-core/pull/6254#issuecomment-1919248687, let's see how he reply. I'll open an issue with more information.

danielhollas commented 5 months ago

Thanks for filing the issue @unkcpz. I've marked this one as blocked since this needs to first be fixed in aiida-core and then we need to wait for a release and publish a new AiiDAlab image.