def test_dist_name(copy_sample): td = copy_sample('altdistname') wheel_main(td / 'flit.ini') res = td / 'dist/package_dist1-0.1-py2.py3-none-any.whl' assert_isfile(res) with unpack(res) as td_unpack: assert_isdir(Path(td_unpack, 'package_dist1-0.1.dist-info'))
def test_permissions_normed(): with tempfile.TemporaryDirectory() as td: shutil.copy(str(samples_dir / 'module1.py'), td) shutil.copy(str(samples_dir / 'module1-pkg.ini'), td) Path(td, 'module1.py').chmod(0o620) wheel_main(Path(td, 'module1-pkg.ini')) whl = Path(td, 'dist', 'module1-0.1-py2.py3-none-any.whl') assert_isfile(whl) with zipfile.ZipFile(str(whl)) as zf: info = zf.getinfo('module1.py') perms = (info.external_attr >> 16) & 0o777 assert perms == 0o644, oct(perms) whl.unlink() # This time with executable bit set Path(td, 'module1.py').chmod(0o720) wheel_main(Path(td, 'module1-pkg.ini')) assert_isfile(whl) with zipfile.ZipFile(str(whl)) as zf: info = zf.getinfo('module1.py') perms = (info.external_attr >> 16) & 0o777 assert perms == 0o755, oct(perms)
def test_upload(): responses.add(responses.POST, upload.PYPI, status=200) with patch('flit.upload.get_repository', return_value=repo_settings): wheel.wheel_main(samples_dir / 'module1-pkg.ini', upload='pypi') assert len(responses.calls) == 1
def test_dist_name(): clear_samples_dist() wheel_main(samples_dir / 'altdistname.ini') res = samples_dir / 'dist/package_dist1-0.1-py2.py3-none-any.whl' assert_isfile(res) with unpack(res) as td: assert_isdir(Path(td, 'package_dist1-0.1.dist-info'))
def test_upload(copy_sample): responses.add(responses.POST, upload.PYPI, status=200) td = copy_sample('module1') with patch('flit.upload.get_repository', return_value=repo_settings): wheel.wheel_main(td / 'flit.ini', upload='pypi') assert len(responses.calls) == 1
def test_wheel_src_package(copy_sample): td = copy_sample('package2') wheel_main(td / 'package2-pkg.ini') whl_file = td / 'dist/package2-0.1-py2.py3-none-any.whl' assert_isfile(whl_file) with unpack(whl_file) as unpacked: print(os.listdir(unpacked)) assert_isfile(Path(unpacked, 'package2', '__init__.py'))
def test_wheel_src_module(copy_sample): td = copy_sample('module3') wheel_main(td / 'flit.ini') whl_file = td / 'dist/module3-0.1-py2.py3-none-any.whl' assert_isfile(whl_file) with unpack(whl_file) as unpacked: assert_isfile(Path(unpacked, 'module3.py')) assert_isdir(Path(unpacked, 'module3-0.1.dist-info')) assert_isfile(Path(unpacked, 'module3-0.1.dist-info', 'LICENSE'))
def test_entry_points(): clear_samples_dist() wheel_main(samples_dir / 'entrypoints_valid.ini') assert_isfile(samples_dir / 'dist/package1-0.1-py2.py3-none-any.whl') with unpack(samples_dir / 'dist/package1-0.1-py2.py3-none-any.whl') as td: entry_points = Path(td, 'package1-0.1.dist-info', 'entry_points.txt') assert_isfile(entry_points) cp = configparser.ConfigParser() cp.read(str(entry_points)) assert 'console_scripts' in cp.sections() assert 'myplugins' in cp.sections()
def test_entry_points(copy_sample): td = copy_sample('entrypoints_valid') wheel_main(td / 'flit.ini') assert_isfile(td / 'dist/package1-0.1-py2.py3-none-any.whl') with unpack(td / 'dist/package1-0.1-py2.py3-none-any.whl') as td_unpack: entry_points = Path(td_unpack, 'package1-0.1.dist-info', 'entry_points.txt') assert_isfile(entry_points) cp = configparser.ConfigParser() cp.read(str(entry_points)) assert 'console_scripts' in cp.sections() assert 'myplugins' in cp.sections()
def test_upload_registers(): with patch('flit.upload.register') as register_mock: def upload_callback(request): status = 200 if register_mock.called else 403 return (status, {}, '') responses.add_callback(responses.POST, upload.PYPI, callback=upload_callback) with patch('flit.upload.get_repository', return_value=repo_settings): wheel.wheel_main(samples_dir / 'module1-pkg.ini', upload='pypi') assert len(responses.calls) == 2 assert register_mock.call_count == 1
def test_upload_registers(): with patch('flit.upload.register') as register_mock: def upload_callback(request): status = 200 if register_mock.called else 403 return (status, {}, '') old_pypi = "https://pypi.python.org/pypi" responses.add_callback(responses.POST, old_pypi, callback=upload_callback) repo = repo_settings.copy() repo['url'] = old_pypi repo['is_warehouse'] = False with patch('flit.upload.get_repository', return_value=repo): wheel.wheel_main(samples_dir / 'module1-pkg.ini', upload='pypi') assert len(responses.calls) == 2 assert register_mock.call_count == 1
def test_permissions_normed(copy_sample): td = copy_sample('module1_ini') (td / 'module1.py').chmod(0o620) wheel_main(td / 'flit.ini') whl = td / 'dist' / 'module1-0.1-py2.py3-none-any.whl' assert_isfile(whl) with zipfile.ZipFile(str(whl)) as zf: info = zf.getinfo('module1.py') perms = (info.external_attr >> 16) & 0o777 assert perms == 0o644, oct(perms) whl.unlink() # This time with executable bit set (td / 'module1.py').chmod(0o720) wheel_main(td / 'flit.ini') assert_isfile(whl) with zipfile.ZipFile(str(whl)) as zf: info = zf.getinfo('module1.py') perms = (info.external_attr >> 16) & 0o777 assert perms == 0o755, oct(perms)
def test_entry_points_conflict(copy_sample): td = copy_sample('entrypoints_conflict') with pytest.raises(EntryPointsConflict): wheel_main(td / 'flit.ini')
def test_entry_points_conflict(): clear_samples_dist() with pytest.raises(EntryPointsConflict): wheel_main(samples_dir / 'entrypoints_conflict.ini')
def test_wheel_module(copy_sample): td = copy_sample('module1_ini') wheel_main(td / 'flit.ini') assert_isfile(td / 'dist/module1-0.1-py2.py3-none-any.whl')
def test_dist_name(): clear_samples_dist() wheel_main(samples_dir / 'altdistname.ini') assert_isfile(samples_dir / 'dist/packagedist1-0.1-py2.py3-none-any.whl')
def test_wheel_package(): clear_samples_dist() wheel_main(samples_dir / 'package1-pkg.ini') assert_isfile(samples_dir / 'dist/package1-0.1-py2.py3-none-any.whl')
def test_wheel_package(copy_sample): td = copy_sample('package1') wheel_main(td / 'flit.ini') assert_isfile(td / 'dist/package1-0.1-py2.py3-none-any.whl')