Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test test_iss1723 is broken #2442

Closed
sbourlon opened this issue Feb 5, 2024 · 5 comments
Closed

Test test_iss1723 is broken #2442

sbourlon opened this issue Feb 5, 2024 · 5 comments

Comments

@sbourlon
Copy link
Contributor

sbourlon commented Feb 5, 2024

Test test_iss1723 is failing on Windows.

See demo in the PR #2441

Environment

Which environment were you using when you encountered the problem?

$ python -m platform
platform win32 -- Python 3.12.1, pytest-7.4.0, pluggy-1.2.0 -- C:\hostedtoolcache\windows\Python\3.12.1\x64\python.exe

$ python -c "import pypdf;print(pypdf._debug_versions)"
main branch

Code + PDF

This is a minimal, complete example that shows the issue:

pytest tests/test_writer.py -k "test_iss1723"

Traceback

This is the complete traceback I see:

================================== FAILURES ===================================
________________________________ test_iss1723 _________________________________
[gw2] win32 -- Python 3.12.1 C:\hostedtoolcache\windows\Python\3.12.1\x64\python.exe
IndexError: size = 4, index: 4

The above exception was the direct cause of the following exception:

    @pytest.mark.enable_socket()
    def test_iss1723():
        # test of an annotation(link) directly stored in the /Annots in the page
        url = "https:/py-pdf/pypdf/files/11015242/inputFile.pdf"
        reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
        writer = PdfWriter()
>       writer.append(reader, (3, 5))

tests\test_writer.py:1412: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pypdf\_writer.py:2261: in append
    self.merge(
pypdf\_writer.py:2345: in merge
    pg = reader.pages[page]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <pypdf._page._VirtualList object at 0x000001A408C085C0>, index = 4

    def __getitem__(
        self, index: Union[int, slice]
    ) -> Union[PageObject, Sequence[PageObject]]:
        if isinstance(index, slice):
            indices = range(*index.indices(len(self)))
            cls = type(self)
            return cls(indices.__len__, lambda idx: self[indices[idx]])
        if not isinstance(index, int):
            raise TypeError("sequence indices must be integers") from TypeError(f"index = {index}")
        len_self = len(self)
        if index < 0:
            # support negative indexes
            index = len_self + index
        if index < 0 or index >= len_self:
>           raise IndexError("sequence index out of range") from IndexError(f"size = {len_self}, index: {index}")
E           IndexError: sequence index out of range

pypdf\_page.py:2225: IndexError
------------------------------ Captured log call ------------------------------
WARNING  pypdf._reader:_utils.py:477 Overwriting cache for 0 589
@stefan6419846
Copy link
Collaborator

I am not seeing these issues in my own fork, thus I would assume that we just have the usual network flakiness here. Re-running the job most likely fixes it.

@sbourlon
Copy link
Contributor Author

sbourlon commented Feb 6, 2024

Thank you Stefan for the answer. Do you have an idea of what did not go through the network? Would it be possible to catch such flakiness?

@stefan6419846
Copy link
Collaborator

It might be sufficient to add the file download to https:/py-pdf/pypdf/blob/main/tests/example_files.yaml, see #2324.

@sbourlon
Copy link
Contributor Author

sbourlon commented Feb 7, 2024

Should be fixed with PR #2440

@stefan6419846
Copy link
Collaborator

Further investigation showed that this seems to indeed by a copy-and-paste error for the filename, thus it owuld depend on the execution order of the test runners whether this would pass or fail.

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

No branches or pull requests

2 participants