当前位置: 首页>>代码示例>>Python>>正文


Python Mock.get_macro方法代码示例

本文整理汇总了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)
开发者ID:timlau,项目名称:FedoraReview,代码行数:29,代码来源:generic_should.py

示例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)
开发者ID:timlau,项目名称:FedoraReview,代码行数:60,代码来源:test_misc.py

示例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)
开发者ID:timlau,项目名称:FedoraReview,代码行数:17,代码来源:ruby.py


注:本文中的FedoraReview.Mock.get_macro方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。