Skip to content

Conversation

@tirkarthi
Copy link
Member

Fixes below warnings that were originally found in CPython test suite.

============================================================================= warnings summary ==============================================================================
importlib_resources/tests/test_resource.py::ResourceFromZipsTest01::test_as_file_directory
  /home/karthikeyan/stuff/python/importlib_resources/importlib_resources/_common.py:206: ResourceWarning: unclosed file <_io.BufferedWriter name='/tmp/tmpekn15a6u/ziptestdata/utf-16.file'>
    child.open('wb').write(source.read_bytes())
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

importlib_resources/tests/test_resource.py::ResourceFromZipsTest01::test_as_file_directory
  /home/karthikeyan/stuff/python/importlib_resources/importlib_resources/_common.py:206: ResourceWarning: unclosed file <_io.BufferedWriter name='/tmp/tmpekn15a6u/ziptestdata/utf-8.file'>
    child.open('wb').write(source.read_bytes())
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

importlib_resources/tests/test_resource.py::ResourceFromZipsTest01::test_as_file_directory
  /home/karthikeyan/stuff/python/importlib_resources/importlib_resources/_common.py:206: ResourceWarning: unclosed file <_io.BufferedWriter name='/tmp/tmpekn15a6u/ziptestdata/__init__.py'>
    child.open('wb').write(source.read_bytes())
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

importlib_resources/tests/test_resource.py::ResourceFromZipsTest01::test_as_file_directory
  /home/karthikeyan/stuff/python/importlib_resources/importlib_resources/_common.py:206: ResourceWarning: unclosed file <_io.BufferedWriter name='/tmp/tmpekn15a6u/ziptestdata/binary.file'>
    child.open('wb').write(source.read_bytes())
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

importlib_resources/tests/test_resource.py::ResourceFromZipsTest01::test_as_file_directory
  /home/karthikeyan/stuff/python/importlib_resources/importlib_resources/_common.py:206: ResourceWarning: unclosed file <_io.BufferedWriter name='/tmp/tmpekn15a6u/ziptestdata/subdirectory/__init__.py'>
    child.open('wb').write(source.read_bytes())
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

importlib_resources/tests/test_resource.py::ResourceFromZipsTest01::test_as_file_directory
  /home/karthikeyan/stuff/python/importlib_resources/importlib_resources/_common.py:206: ResourceWarning: unclosed file <_io.BufferedWriter name='/tmp/tmpekn15a6u/ziptestdata/subdirectory/binary.file'>
    child.open('wb').write(source.read_bytes())
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

@jaraco
Copy link
Member

jaraco commented Dec 6, 2022

I wonder why this test suite doesn't emit the warnings. Aah. So it seems Python ignores ResourceWarnings by default. I've opened jaraco/skeleton#73 to ensure this issue doesn't occur in any other skeleton-backed projects.

@jaraco jaraco merged commit b14f9b5 into python:main Dec 6, 2022
@jaraco
Copy link
Member

jaraco commented Dec 6, 2022

Released as v5.10.1. Will get synced with CPython in the future. I'll try not to let it linger into 2023.

@tirkarthi
Copy link
Member Author

Thanks @jaraco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants