(self)
| 1453 | unlink(filename) |
| 1454 | |
| 1455 | def test_write_pyfile(self): |
| 1456 | self.requiresWriteAccess(os.path.dirname(__file__)) |
| 1457 | with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: |
| 1458 | fn = __file__ |
| 1459 | if fn.endswith('.pyc'): |
| 1460 | path_split = fn.split(os.sep) |
| 1461 | if os.altsep is not None: |
| 1462 | path_split.extend(fn.split(os.altsep)) |
| 1463 | if '__pycache__' in path_split: |
| 1464 | fn = importlib.util.source_from_cache(fn) |
| 1465 | else: |
| 1466 | fn = fn[:-1] |
| 1467 | |
| 1468 | zipfp.writepy(fn) |
| 1469 | |
| 1470 | bn = os.path.basename(fn) |
| 1471 | self.assertNotIn(bn, zipfp.namelist()) |
| 1472 | self.assertCompiledIn(bn, zipfp.namelist()) |
| 1473 | |
| 1474 | with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: |
| 1475 | fn = __file__ |
| 1476 | if fn.endswith('.pyc'): |
| 1477 | fn = fn[:-1] |
| 1478 | |
| 1479 | zipfp.writepy(fn, "testpackage") |
| 1480 | |
| 1481 | bn = "%s/%s" % ("testpackage", os.path.basename(fn)) |
| 1482 | self.assertNotIn(bn, zipfp.namelist()) |
| 1483 | self.assertCompiledIn(bn, zipfp.namelist()) |
| 1484 | |
| 1485 | def test_write_python_package(self): |
| 1486 | import email |
nothing calls this directly
no test coverage detected