Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_method(self, method):
self.l = [LocalFileGetter('{0}plumbum-0.9.0.tar.gz'.format(
self.td_dir)),
LocalFileGetter('{0}Sphinx-1.1.3-py2.6.egg'.format(
self.td_dir)),
LocalFileGetter('{0}unextractable-1.tar'.format(
self.td_dir)),
LocalFileGetter(
'{0}setuptools-19.6-py2.py3-none-any.whl'.format(
self.td_dir)),
LocalFileGetter(
'{0}py2exe-0.9.2.2-py33.py34-none-any.whl'.format(
self.td_dir)),
LocalFileGetter('python-foo-1.tar'),
LocalFileGetter('python-many-dashes-foo-1.tar'),
]
def setup_method(self, method):
self.l = [LocalFileGetter('{0}plumbum-0.9.0.tar.gz'.format(
self.td_dir)),
LocalFileGetter('{0}Sphinx-1.1.3-py2.6.egg'.format(
self.td_dir)),
LocalFileGetter('{0}unextractable-1.tar'.format(
self.td_dir)),
LocalFileGetter(
'{0}setuptools-19.6-py2.py3-none-any.whl'.format(
self.td_dir)),
LocalFileGetter(
'{0}py2exe-0.9.2.2-py33.py34-none-any.whl'.format(
self.td_dir)),
LocalFileGetter('python-foo-1.tar'),
LocalFileGetter('python-many-dashes-foo-1.tar'),
]
('{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 setup_method(self, method):
self.l = [LocalFileGetter('{0}plumbum-0.9.0.tar.gz'.format(
self.td_dir)),
LocalFileGetter('{0}Sphinx-1.1.3-py2.6.egg'.format(
self.td_dir)),
LocalFileGetter('{0}unextractable-1.tar'.format(
self.td_dir)),
LocalFileGetter(
'{0}setuptools-19.6-py2.py3-none-any.whl'.format(
self.td_dir)),
LocalFileGetter(
'{0}py2exe-0.9.2.2-py33.py34-none-any.whl'.format(
self.td_dir)),
LocalFileGetter('python-foo-1.tar'),
LocalFileGetter('python-many-dashes-foo-1.tar'),
]
def test_get_non_existent_file(self):
with pytest.raises(EnvironmentError):
LocalFileGetter('/this/path/doesnot/exist',
tempfile.gettempdir()).get()
def getter(self):
"""Returns an instance of proper PackageGetter subclass. Always
returns the same instance.
Returns:
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