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_doc_files(self, doc_files, license, other):
flexmock(me.SetupPyMetadataExtractor).should_receive(
'doc_files').and_return(doc_files)
data = self.e[0].extract_data()
assert data.data['doc_license'] == license
assert data.data['doc_files'] == other
def setup_method(self, method):
# create fresh extractors for every test
self.nc = NameConvertor('fedora')
self.e = [me.SetupPyMetadataExtractor('{0}plumbum-0.9.0.tar.gz'.format(
self.td_dir), 'plumbum', self.nc, '0.9.0'),
me.SetupPyMetadataExtractor(
'{0}pytest-2.2.3.zip'.format(self.td_dir), 'pytest',
self.nc, '2.2.3'),
me.SetupPyMetadataExtractor(
'{0}bitarray-0.8.0.tar.gz'.format(self.td_dir), 'bitarray',
self.nc, '0.8.0'),
me.SetupPyMetadataExtractor(
'{0}versiontools-1.9.1.tar.gz'.format(self.td_dir),
'versiontools', self.nc, '1.9.1'),
me.SetupPyMetadataExtractor(
'{0}isholiday-0.1.tar.gz'.format(self.td_dir),
'isholiday', self.nc, '0.1'),
]
@me.process_description
def desciption_fce(description):
return description
def setup_method(self, method):
self.nc = NameConvertor('fedora')
self.e = []
for archive, name, version in [
('setuptools-19.6-py2.py3-none-any.whl',
'setuptools', '19.6.2'),
('py2exe-0.9.2.2-py33.py34-none-any.whl',
'py2exe', '0.9.2.2')]:
self.e.append(me.WheelMetadataExtractor('{0}{1}'.format(
self.td_dir, archive), name, self.nc, version, venv=False))
def test_license_from_trove(self, input, expected):
assert me.license_from_trove(input) == expected
def test_cut_to_length(self, text, length, delim, expected):
assert me.cut_to_length(text, length, delim) == expected
Returns:
The proper MetadataExtractor subclass according to local file
suffix.
"""
if not hasattr(self, '_local_file'):
raise AttributeError("local_file attribute must be set before "
"calling metadata_extractor")
if not hasattr(self, '_metadata_extractor'):
if self.local_file.endswith('.whl'):
logger.info("Getting metadata from wheel using "
"WheelMetadataExtractor.")
extractor_cls = metadata_extractors.WheelMetadataExtractor
else:
logger.info("Getting metadata from setup.py using "
"SetupPyMetadataExtractor.")
extractor_cls = metadata_extractors.SetupPyMetadataExtractor
base_python_version = (
self.base_python_version or self.template_base_py_ver)
self._metadata_extractor = extractor_cls(
self.local_file,
self.name,
self.name_convertor,
self.version,
self.rpm_name,
self.venv,
self.distro,
base_python_version)
return self._metadata_extractor
def metadata_extractor(self):
"""Returns an instance of proper MetadataExtractor subclass.
Always returns the same instance.
Returns:
The proper MetadataExtractor subclass according to local file
suffix.
"""
if not hasattr(self, '_local_file'):
raise AttributeError("local_file attribute must be set before "
"calling metadata_extractor")
if not hasattr(self, '_metadata_extractor'):
if self.local_file.endswith('.whl'):
logger.info("Getting metadata from wheel using "
"WheelMetadataExtractor.")
extractor_cls = metadata_extractors.WheelMetadataExtractor
else:
logger.info("Getting metadata from setup.py using "
"SetupPyMetadataExtractor.")
extractor_cls = metadata_extractors.SetupPyMetadataExtractor
base_python_version = (
self.base_python_version or self.template_base_py_ver)
self._metadata_extractor = extractor_cls(
self.local_file,
self.name,
self.name_convertor,
self.version,
self.rpm_name,
self.venv,
self.distro,