MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / test

Function test

scripts/test.py:1305–1511  ·  view source on GitHub ↗
(
        *,
        env_extra,
        implementations,
        venv=False,
        test_names=None,
        pytest_options=None,
        test_timeout=None,
        pytest_prefix=None,
        test_fitz=True,
        pytest_k=None,
        pybind=False,
        system_packages=False,
        )

Source from the content-addressed store, hash-verified

1303
1304
1305def test(
1306 *,
1307 env_extra,
1308 implementations,
1309 venv=False,
1310 test_names=None,
1311 pytest_options=None,
1312 test_timeout=None,
1313 pytest_prefix=None,
1314 test_fitz=True,
1315 pytest_k=None,
1316 pybind=False,
1317 system_packages=False,
1318 ):
1319 if pybind:
1320 cpp_path = 'pymupdf_test_pybind.cpp'
1321 cpp_exe = 'pymupdf_test_pybind.exe'
1322 cpp = textwrap.dedent('''
1323 #include <pybind11/embed.h>
1324
1325 int main()
1326 {
1327 pybind11::scoped_interpreter guard{};
1328 pybind11::exec(R"(
1329 print('Hello world', flush=1)
1330 import pymupdf
1331 pymupdf.JM_mupdf_show_warnings = 1
1332 print(f'{pymupdf.version=}', flush=1)
1333 doc = pymupdf.Document()
1334 pymupdf.mupdf.fz_warn('Dummy warning.')
1335 pymupdf.mupdf.fz_warn('Dummy warning.')
1336 pymupdf.mupdf.fz_warn('Dummy warning.')
1337 print(f'{doc=}', flush=1)
1338 )");
1339 }
1340 ''&#x27;)
1341 def fs_read(path):
1342 try:
1343 with open(path) as f:
1344 return f.read()
1345 except Exception:
1346 return
1347 def fs_remove(path):
1348 try:
1349 os.remove(path)
1350 except Exception:
1351 pass
1352 cpp_existing = fs_read(cpp_path)
1353 if cpp == cpp_existing:
1354 log(f'Not creating {cpp_exe} because unchanged: {cpp_path}')
1355 else:
1356 with open(cpp_path, 'w') as f:
1357 f.write(cpp)
1358 def getmtime(path):
1359 try:
1360 return os.path.getmtime(path)
1361 except Exception:
1362 return 0

Callers 1

mainFunction · 0.70

Calls 9

fs_readFunction · 0.85
getmtimeFunction · 0.85
fs_removeFunction · 0.85
venv_infoFunction · 0.85
removeMethod · 0.80
runFunction · 0.70
logFunction · 0.50
writeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…