Skip to content

TST : unhandle exceptions raised because of Non closed temporary file streams #2394

@pubpub-zz

Description

@pubpub-zz

Environment

side effect of #2379

$ python -m platform
Windows-10-10.0.22621-SP0
python 3.10

$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==3.17.4, crypt_provider=('cryptography', '41.0.1'), PIL=10.1.0

Code + PDF

pytest -k test_writer_operations_by_traditional_usage

Traceback

This is the complete traceback I see:

E               pytest.PytestUnraisableExceptionWarning: Exception ignored in: <_io.FileIO [closed]>
E
E               Traceback (most recent call last):
E                 File "E:\PyPDF4.git\PyPDF2\tests\test_writer.py", line 227, in test_writer_operations_by_traditional_usage
E                   write_data_here = convert(NamedTemporaryFile(suffix=".pdf", delete=needs_cleanup).name)
E               ResourceWarning: unclosed file <_io.BufferedRandom name=15>

C:\Python310\lib\site-packages\_pytest\unraisableexception.py:78: PytestUnraisableExceptionWarning```


## Analysis

the temporary file created is not closed : it should be 

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