def test_wheel_package(): module_path = fixtures_dir / 'complete' WheelBuilder.make(Poetry.create(str(module_path)), NullVenv(), NullIO()) whl = module_path / 'dist' / 'my_package-1.2.3-py3-none-any.whl' assert whl.exists()
def test_wheel_prerelease(): module_path = fixtures_dir / "prerelease" WheelBuilder.make(Poetry.create(str(module_path)), NullVenv(), NullIO()) whl = module_path / "dist" / "prerelease-0.1b1-py2.py3-none-any.whl" assert whl.exists()
def test_package_with_include(mocker): # Patch git module to return specific excluded files p = mocker.patch("poetry.vcs.git.Git.get_ignored_files") p.return_value = [ str( Path(__file__).parent / "fixtures" / "with-include" / "extra_dir" / "vcs_excluded.txt"), str( Path(__file__).parent / "fixtures" / "with-include" / "extra_dir" / "sub_pkg" / "vcs_excluded.txt"), ] module_path = fixtures_dir / "with-include" WheelBuilder.make(Poetry.create(str(module_path)), NullEnv(), NullIO()) whl = module_path / "dist" / "with_include-1.2.3-py3-none-any.whl" assert whl.exists() with zipfile.ZipFile(str(whl)) as z: names = z.namelist() assert len(names) == len(set(names)) assert "with_include-1.2.3.dist-info/LICENSE" in names assert "extra_dir/__init__.py" in names assert "extra_dir/vcs_excluded.txt" in names assert "extra_dir/sub_pkg/__init__.py" in names assert "extra_dir/sub_pkg/vcs_excluded.txt" not in names assert "my_module.py" in names assert "notes.txt" in names assert "package_with_include/__init__.py" in names
def test_wheel_prerelease(): module_path = fixtures_dir / "prerelease" WheelBuilder.make(Poetry.create(str(module_path)), NullEnv(), NullIO()) whl = module_path / "dist" / "prerelease-0.1b1-py2.py3-none-any.whl" assert whl.exists()
def test_wheel_module(): module_path = fixtures_dir / 'module1' WheelBuilder.make(Poetry.create(str(module_path)), NullVenv(), NullIO()) whl = module_path / 'dist' / 'module1-0.1-py2.py3-none-any.whl' assert whl.exists()
def test_wheel_localversionlabel(): module_path = fixtures_dir / "localversionlabel" WheelBuilder.make(Poetry.create(str(module_path)), NullEnv(), NullIO()) local_version_string = "localversionlabel-0.1b1+gitbranch.buildno.1" whl = module_path / "dist" / (local_version_string + "-py2.py3-none-any.whl") assert whl.exists() with zipfile.ZipFile(str(whl)) as z: assert local_version_string + ".dist-info/METADATA" in z.namelist()
def test_wheel_package(): module_path = fixtures_dir / "complete" WheelBuilder.make(Poetry.create(str(module_path)), NullEnv(), NullIO()) whl = module_path / "dist" / "my_package-1.2.3-py3-none-any.whl" assert whl.exists() with zipfile.ZipFile(str(whl)) as z: assert "my_package/sub_pkg1/__init__.py" in z.namelist()
def test_wheel_module_src(): module_path = fixtures_dir / "source_file" WheelBuilder.make(Poetry.create(str(module_path)), NullEnv(), NullIO()) whl = module_path / "dist" / "module_src-0.1-py2.py3-none-any.whl" assert whl.exists() with zipfile.ZipFile(str(whl)) as z: assert "module_src.py" in z.namelist()
def test_wheel_module_src(): module_path = fixtures_dir / "source_file" WheelBuilder.make(Poetry.create(str(module_path)), NullVenv(), NullIO()) whl = module_path / "dist" / "module_src-0.1-py2.py3-none-any.whl" assert whl.exists() z = zipfile.ZipFile(str(whl)) assert "module_src.py" in z.namelist()
def test_wheel_module_src(): module_path = fixtures_dir / 'source_file' WheelBuilder.make(Poetry.create(str(module_path)), NullVenv(), NullIO()) whl = module_path / 'dist' / 'module_src-0.1-py2.py3-none-any.whl' assert whl.exists() z = zipfile.ZipFile(str(whl)) assert 'module_src.py' in z.namelist()
def test_wheel_package(): module_path = fixtures_dir / 'complete' WheelBuilder.make(Poetry.create(str(module_path)), NullVenv(), NullIO()) whl = module_path / 'dist' / 'my_package-1.2.3-py3-none-any.whl' assert whl.exists() z = zipfile.ZipFile(str(whl)) assert 'my_package/sub_pkg1/__init__.py' in z.namelist()
def test_wheel_module(): module_path = fixtures_dir / "module1" WheelBuilder.make(Factory().create_poetry(module_path), NullEnv(), NullIO()) whl = module_path / "dist" / "module1-0.1-py2.py3-none-any.whl" assert whl.exists() with zipfile.ZipFile(str(whl)) as z: assert "module1.py" in z.namelist()
def test_wheel_package(): module_path = fixtures_dir / "complete" WheelBuilder.make(Poetry.create(str(module_path)), NullVenv(), NullIO()) whl = module_path / "dist" / "my_package-1.2.3-py3-none-any.whl" assert whl.exists() z = zipfile.ZipFile(str(whl)) assert "my_package/sub_pkg1/__init__.py" in z.namelist()
def test_wheel_module(): module_path = fixtures_dir / "module1" WheelBuilder.make(Poetry.create(str(module_path)), NullVenv(), NullIO()) whl = module_path / "dist" / "module1-0.1-py2.py3-none-any.whl" assert whl.exists() z = zipfile.ZipFile(str(whl)) assert "module1.py" in z.namelist()
def test_wheel_package_src(): module_path = fixtures_dir / "source_package" WheelBuilder.make(Factory().create_poetry(module_path), NullEnv(), NullIO()) whl = module_path / "dist" / "package_src-0.1-py2.py3-none-any.whl" assert whl.exists() with zipfile.ZipFile(str(whl)) as z: assert "package_src/__init__.py" in z.namelist() assert "package_src/module.py" in z.namelist()
def test_dist_info_file_permissions(): module_path = fixtures_dir / "complete" WheelBuilder.make(Poetry.create(str(module_path)), NullEnv(), NullIO()) whl = module_path / "dist" / "my_package-1.2.3-py3-none-any.whl" with zipfile.ZipFile(str(whl)) as z: assert (z.getinfo("my_package-1.2.3.dist-info/WHEEL").external_attr == 0o644 << 16) assert (z.getinfo("my_package-1.2.3.dist-info/METADATA").external_attr == 0o644 << 16) assert (z.getinfo("my_package-1.2.3.dist-info/RECORD").external_attr == 0o644 << 16) assert (z.getinfo("my_package-1.2.3.dist-info/entry_points.txt"). external_attr == 0o644 << 16)
def test_write_metadata_file_license_homepage_default(mocker): # Preparation mocked_poetry = mocker.Mock() mocked_poetry.file.parent = Path(".") mocked_poetry.package = ProjectPackage("pkg_name", "1.0.0") mocked_file = mocker.Mock() mocked_venv = mocker.Mock() mocked_io = mocker.Mock() # patch Module init inside Builder class mocker.patch("poetry.masonry.builders.builder.Module") w = WheelBuilder(mocked_poetry, mocked_venv, mocked_io) # Action w._write_metadata_file(mocked_file) # Assertion mocked_file.write.assert_any_call("Home-page: UNKNOWN\n") mocked_file.write.assert_any_call("License: UNKNOWN\n")
def test_metadata_file_with_vcs_dependencies(): project_path = fixtures_dir / "with_vcs_dependency" WheelBuilder.make(Poetry.create(str(project_path)), NullEnv(), NullIO()) whl = project_path / "dist" / "with_vcs_dependency-1.2.3-py3-none-any.whl" assert whl.exists() p = Parser() with zipfile.ZipFile(str(whl)) as z: metadata = p.parsestr( to_str(z.read("with_vcs_dependency-1.2.3.dist-info/METADATA")) ) requires_dist = metadata["Requires-Dist"] assert "cleo @ git+https://github.com/sdispater/cleo.git@master" == requires_dist
def build_packages() -> List[Package]: poetry = Factory().create_poetry(Path.cwd()) env = NullEnv() io = NullIO() with TemporaryDirectory() as temp_dir_str: temp_dir = Path(temp_dir_str) wheel_pkg_name = WheelBuilder.make_in(poetry, env, io, temp_dir) pkg_path = temp_dir / wheel_pkg_name pkg_bytes = pkg_path.read_bytes() pkgs = [Package(wheel_pkg_name, pkg_bytes)] return pkgs