Skip to content

Running tests with package installed yields ResourceWarnings #87

@FriedrichFroebel

Description

@FriedrichFroebel

I am currently working on a tests refactoring of one of the packages I maintain (didjvu) and stumbled upon some ResourceWarnings popping up, which seem to originate from vext (the following one is only one example - the same happens for some .py files as well):

<frozen importlib._bootstrap_external>:1359: ResourceWarning: unclosed file <_io.BufferedReader name='/home/me/github/jwilk/env/lib/python3.8/site-packages/gamera/plugins/_runlength.cpython-38-x86_64-linux-gnu.so'>
Object allocated at (most recent call last):
  File "<frozen importlib._bootstrap>", lineno 219
  File "/home/me/github/jwilk/env/lib/python3.8/site-packages/gamera/plugins/runlength.py", lineno 22
    import _runlength
  File "<frozen importlib._bootstrap>", lineno 991
  File "<frozen importlib._bootstrap>", lineno 971
  File "<frozen importlib._bootstrap>", lineno 914
  File "<frozen importlib._bootstrap_external>", lineno 1407
  File "<frozen importlib._bootstrap_external>", lineno 1381
  File "<frozen importlib._bootstrap_external>", lineno 1359
  File "/home/me/github/jwilk/env/lib/python3.8/site-packages/vext/gatekeeper/__init__.py", lineno 253
    module_info = imp.find_module(fullname, [other_path])
  File "/usr/lib/python3.8/imp.py", lineno 302
    file = open(file_path, mode, encoding=encoding)

I am using vext for vext.gi to be available, although the aforementioned code should not actually use any gi imports in theory.

Command: python3 -m unittest discover --start-directory tests/.

For tracing the calls, I enclosed the corresponding test method into

import tracemalloc
tracemalloc.start(10)
...
tracemalloc.stop()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions