Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_extract_site_packages(self, tmpdir, zip_location, nested, compile_pyc, force):
zipfile = ZipFile(str(zip_location))
target = Path(tmpdir, "test")
if nested:
# we want to test for not-yet-created shiv root dirs
target = target / "nested" / "root"
if force:
# we want to make sure we overwrite if the target exists when using force
target.mkdir(parents=True, exist_ok=True)
# Do the extraction (of our empty zip file)
extract_site_packages(zipfile, target, compile_pyc, force=force)
site_packages = target / "site-packages"
assert site_packages.exists()
assert site_packages.is_dir()
assert Path(site_packages, "test").exists()
assert Path(site_packages, "test").is_file()