本文整理汇总了Python中FedoraReview.Mock类的典型用法代码示例。如果您正苦于以下问题:Python Mock类的具体用法?Python Mock怎么用?Python Mock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
# pylint: disable=W0632
def listfiles():
''' Generate listing of dirs and files in each package. '''
with open('files.dir', 'w') as f:
for pkg in self.spec.packages:
nvr = self.spec.get_package_nvr(pkg)
path = Mock.get_package_rpm_path(nvr)
dirs, files = deps.listpaths(path)
f.write(pkg + '\n')
f.write('=' * len(pkg) + '\n')
for line in sorted(dirs):
f.write(line + '\n')
f.write('\n')
for line in sorted(files):
f.write(line + '\n')
f.write('\n')
if Settings.prebuilt:
self.set_passed(self.PENDING, 'Using prebuilt packages')
listfiles()
return
if Settings.nobuild:
if Mock.have_cache_for(self.spec):
self.set_passed(self.PENDING,
'Re-using old build in mock')
return
else:
self.log.info(
'No valid cache, building despite --no-build.')
_mock_root_setup("While building")
Mock.build(self.srpm.filename)
listfiles()
self.set_passed(self.PASS)
示例2: init_test
def init_test(self, cd, argv=[], wd=None,
buildroot=None, options=None):
# Initiate a test which runs in directory cd
# kwargs:
# argv: fed to sys.argv and eventually to Settings
# fedora-review is prepended and mock_root appended.
# wd: review directory, cleared.
# options: mock-options
os.chdir(cd)
if wd:
if os.path.exists(wd):
shutil.rmtree(wd)
ReviewDirs.reset(cd)
ReviewDirs.workdir_setup(os.getcwd(), True)
args = argv
args.insert(0, 'fedora-review')
br = buildroot if buildroot else self.BUILDROOT
args.append("--mock-config=" + br)
opts = []
if NO_NET:
opts.append('--offline')
if options:
opts.append(options)
if opts:
argv.append('--mock-options=' + ' '.join(opts))
sys.argv = argv
Settings.init(True)
Mock.reset()
示例3: init_test
def init_test(self, cd, argv=None, wd=None,
buildroot=None, options=None):
'''
Initiate a test which runs in directory cd
kwargs:
argv: fed to sys.argv and eventually to Settings
fedora-review is prepended and mock_root appended.
wd: review directory, cleared.
options: mock-options'''
cd = os.path.abspath(cd)
os.chdir(cd)
if not wd:
wd = os.getcwd()
ReviewDirs.workdir_setup(wd, 'testing')
if not argv:
argv = []
args = argv
args.insert(0, 'fedora-review')
br = buildroot if buildroot else self.BUILDROOT
args.append("--mock-config=" + br)
opts = []
if NO_NET:
opts.append('--offline')
if options:
opts.append(options)
if opts:
argv.append('--mock-options=' + ' '.join(opts))
sys.argv = argv
Settings.init(True)
Mock.clear_builddir()
Mock.reset()
示例4: test_mock_configdir
def test_mock_configdir(self):
self.init_test('test_misc',
argv=['-n','python-test'],
buildroot='default',
options='--configdir=mock-config')
Mock.reset()
Mock._get_root()
self.assertEqual(Mock.mock_root, 'fedora-12-i786')
示例5: check_build_installed
def check_build_installed(self):
''' Return list of used rpms which are not installed'''
bad_ones = []
for pkg in self.spec.packages:
try:
nvr = self.spec.get_package_nvr(pkg)
Mock.get_package_rpm_path(nvr)
except ReviewError:
bad_ones.append(pkg)
return bad_ones
示例6: setUp
def setUp(self):
FR_TestCase.setUp(self)
sys.argv = ['fedora-review', '-b', '1']
Settings.init(True)
self.spec_file = os.path.join(os.path.abspath('.'),
'test_regressions',
'test_107_1.spec')
self.srpm_file = os.path.join(os.path.abspath('.'),
'test_regressions',
'test_107_1-1.0-1.fc17.src.rpm')
Mock.reset()
示例7: run
def run(self):
if self.checks.checkdict['CheckPackageInstalls'].is_passed:
rpms = Mock.get_package_rpm_paths(self.spec)
no_errors, retcode = Mock.rpmlint_rpms(rpms)
text = 'No rpmlint messages.' if no_errors else \
'There are rpmlint messages (see attachment).'
attachments = \
[self.Attachment('Rpmlint (installed packages)',
retcode + '\n', 5)]
self.set_passed(self.PASS, text, attachments)
else:
self.set_passed(self.FAIL, 'Mock build failed')
示例8: test_mock_clear
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)
示例9: setUp
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()
示例10: setUp
def setUp(self):
if not srcpath.PLUGIN_PATH in sys.path:
sys.path.append(srcpath.PLUGIN_PATH)
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.fc17.src.rpm')
self.startdir = os.getcwd()
Mock.reset()
示例11: setUp
def setUp(self):
sys.argv = ['fedora-review', '-b', '1']
self.startdir = os.getcwd()
Settings.init(True)
self.log = Settings.get_logger()
self.helpers = HelpersMixin()
self.spec_file = os.path.join(os.path.abspath('.'),
'test_regressions',
'test_107_1.spec')
self.srpm_file = os.path.join(os.path.abspath('.'),
'test_regressions',
'test_107_1-1.0-1.fc17.src.rpm')
Mock.reset()
示例12: test_mock_options
def test_mock_options(self):
''' test -o/--mock-options and -m/mock-config '''
nextrelease = '%d' % (int(RELEASE) + 1)
v = nextrelease if RELEASE in self.BUILDROOT else RELEASE
buildroot = 'fedora-%s-i386' % v
self.init_test('mock-options',
argv = ['-n', 'python-test', '--cache'],
options='--resultdir=results --uniqueext=foo',
buildroot=buildroot)
bug = NameBug('python-test')
bug.find_urls()
bug.download_files()
mock_cmd = ' '.join(Mock._mock_cmd())
Mock._get_root()
self.assertIn('-r ' + buildroot, mock_cmd)
self.assertEqual(Mock.mock_root, buildroot + '-foo')
示例13: run
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)
示例14: rpmlint_rpms
def rpmlint_rpms(self):
""" Runs rpmlint against the used rpms - prebuilt or built in mock.
"""
# pylint: disable=E1123
rpms = Mock.get_package_rpm_paths(self.spec, with_srpm=True)
no_errors, result = self.run_rpmlint(rpms)
return no_errors, result + '\n'
示例15: _mock_root_setup
def _mock_root_setup(while_what, force=False):
''' Wrap mock --init. '''
class DependencyInstallError(ReviewError):
''' Raised when a package in local repo can't be installed. '''
pass
Mock.init(force)
if Settings.repo:
repodir = Settings.repo
if not repodir.startswith('/'):
repodir = os.path.join(ReviewDirs.startdir, repodir)
rpms = glob.glob(os.path.join(repodir, '*.rpm'))
error = Mock.install(rpms)
if error:
raise DependencyInstallError(while_what + ': ' + error)