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_get_nonexistent_attribute(self):
pd = PackageData('spam', 'spam', 'python-spam', 'spam')
assert pd.eggs == 'TODO:'
def test_merge_versions_fedora(self, self_bv, self_pv, data_pv,
expected_bv, expected_pv):
c = Convertor(package='pkg', base_python_version=self_bv,
python_versions=self_pv, template='fedora.spec')
data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1')
data.python_versions = data_pv
c.merge_versions(data)
assert data.base_python_version == expected_bv
assert data.python_versions == expected_pv
def test_update_attr(self, key, init, update_data, expected):
pd = PackageData('spam', init, 'python-spam', 'spam')
pd.set_from(update_data, update=True)
assert pd.data[key] == expected
def test_bad_versions(self, self_bv, self_pv):
c = Convertor(package='pkg', base_python_version=self_bv,
python_versions=self_pv, template='epel6.spec',
distro='epel6')
data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1')
with pytest.raises(SystemExit):
c.merge_versions(data)
def test_set_none_value(self, name):
pd = PackageData('spam', 'spam', 'python-spam', 'spam')
setattr(pd, name, None)
actual = getattr(pd, name)
assert actual == 'TODO:'
def test_underscored_name(self, n, expected):
pd = PackageData('spam', n, 'python-spam', 'spam')
assert pd.underscored_name == expected
def test_summary_with_dot(self, s, expected):
pd = PackageData('spam', 'spam', 'python-spam', 'spam')
pd.summary = s
assert pd.summary == expected
def test_merge_versions_epel6(self, self_bv, self_pv, data_bv, data_pv,
expected_bv, expected_pv):
c = Convertor(package='pkg', base_python_version=self_bv,
python_versions=self_pv, template='epel6.spec',
distro='epel6')
data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1')
data.base_python_version = data_bv
data.python_versions = data_pv
c.merge_versions(data)
assert data.base_python_version == expected_bv
assert data.python_versions == expected_pv
def test_merge_versions_epel7(self, self_bv, self_pv, data_pv,
expected_bv, expected_pv):
c = Convertor(package='pkg', base_python_version=self_bv,
python_versions=self_pv, template='epel7.spec',
distro='epel7')
data = PackageData('pkg.tar.gz', 'pkg', 'pkg', '0.1')
data.python_versions = data_pv
c.merge_versions(data)
assert data.base_python_version == expected_bv
assert data.python_versions == expected_pv
def extract_data(self):
"""Extracts data from archive.
Returns:
PackageData object containing the extracted data.
"""
data = PackageData(
local_file=self.local_file,
name=self.name,
pkg_name=self.rpm_name or self.name_convertor.rpm_name(
self.name, pkg_name=True),
version=self.version,
srcname=self.srcname)
with self.archive:
data.set_from(self.data_from_archive)
# for example nose has attribute `packages` but instead of name
# listing the pacakges is using function to find them, that makes
# data.packages an empty set if virtualenv is disabled
if self.venv_extraction_disabled and getattr(data, "packages") == []:
data.packages = [data.name]