forked from pymupdf/PyMuPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap all tests to check no MuPDF warning text is generated.
In particular this detects warnings about not calling fz_close_output() before fz_drop_output() etc, which have been fixed in this commit. For some tests that are still expected to generate warnings, we consume these warnings before returning. We disable these new tests if using classic implementation of PyMuPDF, or rebased with mupdf version < 1.25.
- Loading branch information
1 parent
6c9c56e
commit 0a0ecf1
Showing
11 changed files
with
112 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import fitz | ||
import pytest | ||
|
||
@pytest.fixture(autouse=True) | ||
def wrap(*args, **kwargs): | ||
''' | ||
Check that tests return with empty MuPDF warnings buffer. For example this | ||
detects failure to call fz_close_output() before fz_drop_output(), which | ||
(as of 2024-4-12) generates a warning from MuPDF. | ||
''' | ||
wt = fitz.TOOLS.mupdf_warnings() | ||
assert not wt, f'{wt=}' | ||
|
||
# Run the test. | ||
rep = yield | ||
|
||
# Test has run; check it did not create any MuPDF warnings. | ||
wt = fitz.TOOLS.mupdf_warnings() | ||
if not hasattr(fitz, 'mupdf'): | ||
print(f'Not checking mupdf_warnings on classic.') | ||
else: | ||
assert not wt, f'Warnings text not empty: {wt=}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters