本文整理汇总了Python中FedoraReview.Mock.get_macro方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.get_macro方法的具体用法?Python Mock.get_macro怎么用?Python Mock.get_macro使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FedoraReview.Mock
的用法示例。
在下文中一共展示了Mock.get_macro方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from FedoraReview import Mock [as 别名]
# 或者: from FedoraReview.Mock import get_macro [as 别名]
def run(self):
bad_pkgs = []
archs = self.checks.spec.expand_tag('BuildArchs')
if len(self.spec.packages) == 1:
self.set_passed(self.NA)
return
if len(archs) == 1 and archs[0].lower() == 'noarch':
isa = ''
else:
isa = Mock.get_macro('%_isa', self.spec, self.flags)
regex = self.REGEX.replace('%{?_isa}', isa)
regex = rpm.expandMacro(regex)
regex = re.sub('[.](fc|el)[0-9]+', '', regex)
for pkg in self.spec.packages:
if pkg == self.spec.base_package:
continue
for pkg_end in ['debuginfo', '-javadoc', '-doc']:
if pkg.endswith(pkg_end):
continue
reqs = ''.join(self.rpms.get(pkg).format_requires)
if regex not in reqs:
bad_pkgs.append(pkg)
if bad_pkgs:
self.set_passed(self.PENDING,
self.HDR + ' , '.join(bad_pkgs))
else:
self.set_passed(self.PASS)
示例2: test_spec_file
# 需要导入模块: from FedoraReview import Mock [as 别名]
# 或者: from FedoraReview.Mock import get_macro [as 别名]
def test_spec_file(self):
''' Test the SpecFile class'''
def fix_usr_link(path):
''' Convert absolute paths to /usr/path. '''
if not '/' in path:
return path
lead = path.split('/')[1]
if lead in ['bin', 'sbin', 'lib', 'lib64']:
return '/usr' + path
return path
self.init_test('test_misc',
argv=['-n', 'python-test', '--no-build'])
spec = SpecFile(os.path.join(os.getcwd(), 'python-test.spec'))
self.assertEqual(spec.name, 'python-test')
self.assertEqual(spec.version, '1.0')
dist = Mock.get_macro('%dist', None, {})
self.assertEqual(spec.release, '1' + dist)
self.assertEqual(spec.expand_tag('Release'), '1' + dist)
self.assertEqual(spec.expand_tag('License'), 'GPLv2+')
self.assertEqual(spec.expand_tag('Group'), 'Development/Languages')
# Test rpm value not there
self.assertEqual(spec.expand_tag('PreReq'), None)
# Test get sections
expected = ['rm -rf $RPM_BUILD_ROOT']
self.assertEqual(spec.get_section('%clean'), expected)
expected = '%{__python} setup.py build'
expected = ['LANG=C', 'export LANG', 'unset DISPLAY',
'/usr/bin/python setup.py build']
build = spec.get_section('%build')
build = map(fix_usr_link, build)
self.assertIn(''.join(build), ''.join(expected))
install = spec.get_section('%install')
install = map(fix_usr_link, install)
expected = ['LANG=C', 'export LANG', 'unset DISPLAY',
'rm -rf $RPM_BUILD_ROOT',
'/usr/bin/python setup.py install -O1 --skip-build'
' --root $RPM_BUILD_ROOT']
self.assertIn(''.join(install), ''.join(expected))
# Test get_sources (return the Source/Patch lines with macros resolved)
expected = {'Source0': 'http://timlau.fedorapeople.org/'
'files/test/review-test/python-test-1.0.tar.gz'}
self.assertEqual(spec.sources_by_tag, expected)
expected = ['%defattr(-,root,root,-)',
'%doc COPYING',
rpm.expandMacro('%{python_sitelib}') + '/*']
self.assertEqual(spec.get_files(), expected)
# Test find
regex = re.compile(r'^Release\s*:\s*(.*)')
res = spec.find_re(regex)
if res:
self.assertEqual(res.split(':')[1].strip(), '1%{?dist}')
else:
self.assertTrue(False)
示例3: run_on_applicable
# 需要导入模块: from FedoraReview import Mock [as 别名]
# 或者: from FedoraReview.Mock import get_macro [as 别名]
def run_on_applicable(self):
try:
fedora_vers = int(Mock.get_macro("%fedora", self.spec, self.flags))
except ValueError:
# EPEL?
fedora_vers = 20
if fedora_vers <= 20:
self.set_passed(self.NA)
return
failed = self.spec.find_re(r'Requires:\s*rubygem\s*$')
if failed:
text = 'Obsolete %s found in spec' % failed
self.set_passed(self.FAIL, text)
else:
self.set_passed(self.PASS)