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_init_good_data(self, name, version, expected_ver):
d = PypiDownloader(self.client, name, version)
assert d.version == expected_ver
def test_init_bad_data(self, name, version):
with pytest.raises(NoSuchPackageException):
PypiDownloader(self.client, name, version)
('spam', PypiDownloader),
('{0}restsh-0.1.tar.gz'.format(td_dir), LocalFileGetter)
])
def test_getter_good_data(self, sf, g):
c = Convertor(package=sf)
assert isinstance(c.getter, g)
def test_init_good_data_pre(self, name, version, expected_ver):
d = PypiDownloader(self.client, name, version, prerelease=True)
assert d.version == expected_ver
Instance of the proper PackageGetter subclass according to
provided argument.
Raises:
NoSuchSourceException if source to get the package from is unknown
NoSuchPackageException if the package is unknown on PyPI
"""
if not hasattr(self, '_getter'):
if not self.pypi:
self._getter = package_getters.LocalFileGetter(
self.package,
self.save_dir)
else:
logger.debug(
'{0} does not exist as local file trying PyPI.'.format(
self.package))
self._getter = package_getters.PypiDownloader(
self.client,
self.package,
self.version,
self.prerelease,
self.save_dir)
return self._getter