(
zipapp, # type: str
test_run=True, # type: bool
)
| 523 | # type: (Any) -> None |
| 524 | |
| 525 | def assert_perform_check_zip64_handling( |
| 526 | zipapp, # type: str |
| 527 | test_run=True, # type: bool |
| 528 | ): |
| 529 | # type: (...) -> None |
| 530 | assert Check.NONE.perform_check(Layout.ZIPAPP, zipapp) is None |
| 531 | assert Check.ERROR.perform_check(Layout.PACKED, zipapp) is None |
| 532 | assert Check.ERROR.perform_check(Layout.LOOSE, zipapp) is None |
| 533 | |
| 534 | # Python 3.13 newly supports ZIP64 in `zipimport.zipimporter`. |
| 535 | if sys.version_info >= (3, 13): |
| 536 | assert Check.WARN.perform_check(Layout.ZIPAPP, zipapp) is True |
| 537 | assert Check.ERROR.perform_check(Layout.ZIPAPP, zipapp) is True |
| 538 | if test_run: |
| 539 | subprocess.check_call(args=[sys.executable, zipapp]) |
| 540 | else: |
| 541 | expected_error_message_re = r"The PEX zip at {path} is not a valid zipapp: ".format( |
| 542 | path=re.escape(zipapp) |
| 543 | ) |
| 544 | with pytest.warns(PEXWarning, match=expected_error_message_re): |
| 545 | assert Check.WARN.perform_check(Layout.ZIPAPP, zipapp) is False |
| 546 | with pytest.raises(InvalidZipAppError, match=expected_error_message_re): |
| 547 | Check.ERROR.perform_check(Layout.ZIPAPP, zipapp) |
| 548 | |
| 549 | if test_run: |
| 550 | assert subprocess.call(args=[sys.executable, zipapp]) != 0 |
| 551 | |
| 552 | @contextmanager |
| 553 | def write_zipapp(path): |
no test coverage detected