Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/fitz___init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

# pylint: disable=wildcard-import,unused-import,unused-wildcard-import,no-name-in-module
from pymupdf import *
from pymupdf import _as_fz_document
Expand All @@ -12,4 +14,7 @@
from pymupdf import _globals
from pymupdf import _g_out_message

message_warning('The `fitz` API is deprecated and will be removed in future. Use `import pymupdf` instead.')
warnings.warn(
'The `fitz` API is deprecated and will be removed in future. Use `import pymupdf` instead.',
FutureWarning,
)
34 changes: 34 additions & 0 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -2281,3 +2281,37 @@ def test_5054():
assert text2 != text1
else:
assert text2 == text1

def test_5100():
print()

def run(code):
code = textwrap.dedent(code)
print(f'code is:\n{textwrap.indent(code, " ")}')
path = os.path.normpath(f'{__file__}/../../tests/_test_5100.py')
with open(path, 'w') as f:
f.write(code)
cp = subprocess.run(f'{sys.executable} {path}', shell=1, check=1, capture_output=1)
print(f'{cp.stdout=}')
print(f'{cp.stderr=}')
return cp

cp = run('''
import pymupdf
''')
assert cp.stdout == b''
assert cp.stderr == b''

cp = run('''
import fitz
''')
assert cp.stdout == b''
assert b'FutureWarning: The `fitz` API is deprecated and will be removed in future. Use `import pymupdf` instead' in cp.stderr

cp = run('''
import warnings
warnings.filterwarnings('ignore', category=FutureWarning, module='fitz')
import fitz
''')
assert cp.stdout == b''
assert cp.stderr == b''
Loading