def test_help(): """ Test wheel2deb -h """ with TemporaryDirectory() as directory: os.chdir(directory) with pytest.raises(SystemExit) as e: wheel2deb.main() assert e.code == 0
def test_build(tmp_path): os.chdir(str(tmp_path)) os.mkdir('output') with patch.object(sys, 'argv', ['', 'build', '-f', '-j1']): with pytest.raises(SystemExit) as e: wheel2deb.main() assert e.code == 0
def test_build(tmp_path): os.chdir(str(tmp_path)) os.mkdir("output") with patch.object(sys, "argv", ["", "build", "-f", "-j1"]): with pytest.raises(SystemExit) as e: wheel2deb.main() assert e.code == 0
def test_conversion(tmp_path, wheel_path): """ Test the conversion of a dummy wheel foobar """ os.chdir(str(tmp_path)) # convert wheel to debian source package with patch.object(sys, 'argv', ['', '-x', str(wheel_path.parent)]): with patch.object(wheel2deb.sys, "exit") as mock_exit: wheel2deb.main() assert mock_exit.call_args[0][0] == 0 unpack_path = tmp_path / 'output/python3-foobar_0.1.0-1~w2d0_all' assert unpack_path.exists() # build source package with patch.object(sys, 'argv', ['', 'build']): with patch.object(wheel2deb.sys, "exit") as mock_exit: wheel2deb.main() assert mock_exit.call_args[0][0] == 0 # output dir should contain a .deb package_list = list((tmp_path / 'output').glob('*.deb')) assert package_list package_path = package_list[0] assert package_path.name.startswith('python3-foobar_0.1.0-1') package_hash = digests(package_list[0]) endpoint_python_version = "" if sys.version_info[0] >= 3: endpoint_python_version = str(sys.version_info[0]) # check that the entrypoint will be installed in /usr/bin entrypoint = (unpack_path / ('debian/python3-foobar/usr/bin/entrypoint'+endpoint_python_version)) assert entrypoint.exists() # check shebang with open(str(entrypoint), 'r') as f: shebang = f.readline() assert shebang.startswith('#!/usr/bin') # idempotence: delete package, rerun build command # and check that both packages have the same hash package_list[0].unlink() with patch.object(sys, 'argv', ['', 'build']): with patch.object(wheel2deb.sys, "exit") as mock_exit: wheel2deb.main() assert mock_exit.call_args[0][0] == 0 assert digests(package_path) == package_hash
def test_conversion(tmp_path, wheel_path): """ Test the conversion of a dummy wheel foobar """ os.chdir(str(tmp_path)) # convert wheel to debian source package with patch.object(sys, "argv", ["", "-x", str(wheel_path.parent)]): with patch.object(wheel2deb.sys, "exit") as mock_exit: wheel2deb.main() assert mock_exit.call_args[0][0] == 0 unpack_path = tmp_path / "output/python3-foobar_0.1.0-1~w2d0_all" assert unpack_path.exists() # build source package with patch.object(sys, "argv", ["", "build"]): with patch.object(wheel2deb.sys, "exit") as mock_exit: wheel2deb.main() assert mock_exit.call_args[0][0] == 0 # output dir should contain a .deb package_list = list((tmp_path / "output").glob("*.deb")) assert package_list package_path = package_list[0] assert package_path.name.startswith("python3-foobar_0.1.0-1") package_hash = digests(package_list[0]) # check that the entrypoint will be installed in /usr/bin entrypoint = unpack_path / "debian/python3-foobar/usr/bin/entrypoint" assert entrypoint.exists() # check shebang with open(str(entrypoint), "r") as f: shebang = f.readline() assert shebang.startswith("#!/usr/bin") # idempotence: delete package, rerun build command # and check that both packages have the same hash package_list[0].unlink() with patch.object(sys, "argv", ["", "build"]): with patch.object(wheel2deb.sys, "exit") as mock_exit: wheel2deb.main() assert mock_exit.call_args[0][0] == 0 assert digests(package_path) == package_hash