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_wheel_src_module(copy_sample):
td = copy_sample('module3')
make_wheel_in(td / 'flit.ini', td)
whl_file = td / '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_dist_name(self):
Installer.from_ini_path(samples_dir / 'altdistname' / 'pyproject.toml').install_directly()
assert_isdir(self.tmpdir / 'site-packages' / 'package1')
assert_isdir(self.tmpdir / 'site-packages' / 'package_dist1-0.1.dist-info')
def test_dist_name(copy_sample):
td = copy_sample('altdistname')
make_wheel_in(td / 'flit.ini', td)
res = td / '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_install_package(self):
oldcwd = os.getcwd()
os.chdir(str(samples_dir / 'package1'))
try:
Installer.from_ini_path(pathlib.Path('pyproject.toml')).install_directly()
finally:
os.chdir(oldcwd)
assert_isdir(self.tmpdir / 'site-packages' / 'package1')
assert_isdir(self.tmpdir / 'site-packages' / 'package1-0.1.dist-info')
assert_isfile(self.tmpdir / 'scripts' / 'pkg_script')
with (self.tmpdir / 'scripts' / 'pkg_script').open() as f:
assert f.readline().strip() == "#!" + sys.executable
self._assert_direct_url(
samples_dir / 'package1', 'package1', '0.1', expected_editable=False
)
def test_install_module(self):
Installer.from_ini_path(samples_dir / 'module1_toml' / 'pyproject.toml').install_directly()
assert_isfile(self.tmpdir / 'site-packages' / 'module1.py')
assert_isdir(self.tmpdir / 'site-packages' / 'module1-0.1.dist-info')
self._assert_direct_url(
samples_dir / 'module1_toml', 'module1', '0.1', expected_editable=False
)
def test_build_main(copy_sample):
td = copy_sample('module1_toml')
(td / '.git').mkdir() # Fake a git repo
with MockCommand('git', LIST_FILES_TEMPLATE.format(
python=sys.executable, module='module1.py')):
res = build.main(td / 'pyproject.toml')
assert res.wheel.file.suffix == '.whl'
assert res.sdist.file.name.endswith('.tar.gz')
assert_isdir(td / 'dist')