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


Python Mock.get_builddir方法代码示例

本文整理汇总了Python中FedoraReview.Mock.get_builddir方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.get_builddir方法的具体用法?Python Mock.get_builddir怎么用?Python Mock.get_builddir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FedoraReview.Mock的用法示例。


在下文中一共展示了Mock.get_builddir方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_spec_file

# 需要导入模块: from FedoraReview import Mock [as 别名]
# 或者: from FedoraReview.Mock import get_builddir [as 别名]
 def test_spec_file(self):
     ''' Test the SpecFile class'''
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     dest = Mock.get_builddir('SOURCES')
     if not os.path.exists(dest):
         os.makedirs(dest)
     self.helpers._get_file(TEST_SPEC, Mock.get_builddir('SOURCES'))
     spec = SpecFile(self.spec_file)
     # Test misc rpm values (Macro resolved)
     self.assertEqual(spec.name,'python-test')
     self.assertEqual(spec.version,'1.0')
     # resolve the dist-tag
     dist = self.helpers._run_cmd('rpm --eval %dist')[:-1]
     self.assertEqual(spec.release,'1'+dist)
     # test misc rpm values (without macro resolve)
     self.assertEqual(spec.find_tag('Release'), ['1%{?dist}'])
     self.assertEqual(spec.find_tag('License'), ['GPLv2+'])
     self.assertEqual(spec.find_tag('Group'), ['Development/Languages'])
     # Test rpm value not there
     self.assertEqual(spec.find_tag('PreReq'), [])
     # Test get sections
     expected = {'%clean': ['rm -rf $RPM_BUILD_ROOT']}
     self.assertEqual(spec.get_section('%clean'), expected)
     expected = {'%build': ['%{__python} setup.py build']}
     self.assertEqual(spec.get_section('%build'), expected)
     expected = {'%install': ['rm -rf $RPM_BUILD_ROOT', 
                 '%{__python} setup.py install -O1 --skip-build'
                 ' --root $RPM_BUILD_ROOT']}
     self.assertEqual(spec.get_section('%install'),expected)
     expected = {'%files': ['%defattr(-,root,root,-)', 
                 '%doc COPYING', '%{python_sitelib}/*']}
     self.assertEqual(spec.get_section('%files'),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.get_sources(), expected)
     # Test find
     regex = re.compile(r'^Release\s*:\s*(.*)')
     res = spec.find(regex)
     if res:
         self.assertEqual(res.groups(), ('1%{?dist}',))
     else:
         self.assertTrue(False)
     os.chdir(self.startdir)
开发者ID:hadrons123,项目名称:FedoraReview,代码行数:47,代码来源:test_misc.py

示例2: test_mock_clear

# 需要导入模块: from FedoraReview import Mock [as 别名]
# 或者: from FedoraReview.Mock import get_builddir [as 别名]
 def test_mock_clear(self):
     ''' test mock.clear_builddir(). '''
     self.init_test('test_misc',
                    argv=['-n', 'python-test', '--cache',
                          '--no-build'])
     wdir = Mock.get_builddir('BUILD')
     len1 = len(glob.glob(os.path.join(wdir, "*")))
     s = "cd {0}; ln -sf foo bar || :".format(wdir)
     check_output(s, shell=True)
     Mock.builddir_cleanup()
     len2 = len(glob.glob(os.path.join(wdir, "*")))
     self.assertEqual(len2, len1)
开发者ID:athos-ribeiro,项目名称:FedoraReview,代码行数:14,代码来源:test_misc.py

示例3: setUp

# 需要导入模块: from FedoraReview import Mock [as 别名]
# 或者: from FedoraReview.Mock import get_builddir [as 别名]
 def setUp(self):
     sys.argv = ['fedora-review','-n','python-test','--prebuilt']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     self.log = Settings.get_logger()
     self.helpers = Helpers()
     self.srpm_file = os.path.join(os.path.abspath('.'),
                                   os.path.basename(TEST_SRPM))
     self.spec_file = os.path.join(Mock.get_builddir('SOURCES'),
                                     os.path.basename(TEST_SPEC))
     self.source_file = os.path.join(Mock.get_builddir('SOURCES'),
                                     os.path.basename(TEST_SRC))
     if not os.path.exists(TEST_WORK_DIR):
         os.makedirs(TEST_WORK_DIR)
     self.helpers._get_file(TEST_SRPM, TEST_WORK_DIR)
     self.startdir = os.getcwd()
     for tree in ['python-test', 'results']:
         if os.path.exists(tree):
             shutil.rmtree(tree)
     Mock.reset()
开发者ID:hadrons123,项目名称:FedoraReview,代码行数:23,代码来源:test_misc.py

示例4: setUp

# 需要导入模块: from FedoraReview import Mock [as 别名]
# 或者: from FedoraReview.Mock import get_builddir [as 别名]
 def setUp(self):
     sys.argv = ['fedora-review', '-b', '1']
     Settings.init(True)
     self.log = Settings.get_logger()
     self.helpers = HelpersMixin()
     self.srpm_file = os.path.join(os.path.abspath('.'),
                                   'test_misc',
                                   'python-test-1.0-1.fc16.src.rpm')
     self.spec_file = os.path.join(Mock.get_builddir('SOURCES'),
                                   'python-test.spec')
     self.startdir = os.getcwd()
     Mock.reset()
开发者ID:pombredanne,项目名称:FedoraReview,代码行数:14,代码来源:test_misc.py

示例5: __run_checks

# 需要导入模块: from FedoraReview import Mock [as 别名]
# 或者: from FedoraReview.Mock import get_builddir [as 别名]
 def __run_checks(self, spec, srpm):
     self.checks = Checks(spec, srpm )
     if Settings.no_report:
         self.outfile = '/dev/null'
     else:
         self.outfile = ReviewDirs.report_path(self.checks.spec.name)
     with open(self.outfile,"w") as output:
         if Settings.nobuild:
             self.checks.srpm.is_build = True
         self.log.info('Running checks and generate report\n')
         self.checks.run_checks(output=output,
                                writedown=not Settings.no_report)
         output.close()
     if not os.path.exists('BUILD'):
         os.symlink(Mock.get_builddir('BUILD'), 'BUILD')
     if not Settings.no_report:
         print "Review in: " + self.outfile
开发者ID:hadrons123,项目名称:FedoraReview,代码行数:19,代码来源:review_helper.py

示例6: run

# 需要导入模块: from FedoraReview import Mock [as 别名]
# 或者: from FedoraReview.Mock import get_builddir [as 别名]
 def run(self):
     if not Mock.is_available():
         self.set_passed(self.NA)
         return
     Mock.clear_builddir()
     errmsg = Mock.rpmbuild_bp(self.srpm)
     if errmsg:
         self.log.debug(
             "Cannot do rpmbuild -bp, trying with builddeps")
         Mock.install(self.spec.build_requires)
         Mock.rpmbuild_bp(self.srpm)
     if os.path.lexists('BUILD'):
         if os.path.islink('BUILD'):
             os.unlink('BUILD')
         else:
             shutil.rmtree('BUILD')
     os.symlink(Mock.get_builddir('BUILD'), 'BUILD')
     self.log.info('Active plugins: ' +
                       ', '.join(self.checks.get_plugins(True)))
     self.set_passed(self.NA, None, [self.setup_attachment()])
开发者ID:athos-ribeiro,项目名称:FedoraReview,代码行数:22,代码来源:generic_build.py

示例7: test_spec_file

# 需要导入模块: from FedoraReview import Mock [as 别名]
# 或者: from FedoraReview.Mock import get_builddir [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'])
        dest = Mock.get_builddir('SOURCES')
        if not os.path.exists(dest):
            os.makedirs(dest)
        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:athos-ribeiro,项目名称:FedoraReview,代码行数:63,代码来源:test_misc.py


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