MCPcopy Create free account
hub / github.com/RustPython/RustPython / test_write_pyfile

Method test_write_pyfile

Lib/test/test_zipfile/test_core.py:1435–1463  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1433
1434 @unittest.expectedFailure # TODO: RUSTPYTHON
1435 def test_write_pyfile(self):
1436 self.requiresWriteAccess(os.path.dirname(__file__))
1437 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
1438 fn = __file__
1439 if fn.endswith('.pyc'):
1440 path_split = fn.split(os.sep)
1441 if os.altsep is not None:
1442 path_split.extend(fn.split(os.altsep))
1443 if '__pycache__' in path_split:
1444 fn = importlib.util.source_from_cache(fn)
1445 else:
1446 fn = fn[:-1]
1447
1448 zipfp.writepy(fn)
1449
1450 bn = os.path.basename(fn)
1451 self.assertNotIn(bn, zipfp.namelist())
1452 self.assertCompiledIn(bn, zipfp.namelist())
1453
1454 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
1455 fn = __file__
1456 if fn.endswith('.pyc'):
1457 fn = fn[:-1]
1458
1459 zipfp.writepy(fn, "testpackage")
1460
1461 bn = "%s/%s" % ("testpackage", os.path.basename(fn))
1462 self.assertNotIn(bn, zipfp.namelist())
1463 self.assertCompiledIn(bn, zipfp.namelist())
1464
1465 @unittest.expectedFailure # TODO: RUSTPYTHON
1466 def test_write_python_package(self):

Callers

nothing calls this directly

Calls 10

requiresWriteAccessMethod · 0.95
assertCompiledInMethod · 0.95
TemporaryFileFunction · 0.90
writepyMethod · 0.80
basenameMethod · 0.80
assertNotInMethod · 0.80
endswithMethod · 0.45
splitMethod · 0.45
extendMethod · 0.45
namelistMethod · 0.45

Tested by

no test coverage detected