Stop using str.format

On Python 2.6, it requires the format placeholder to have explicit index
of argument, so using % formatting is easier.

There are a couple places where the method is still used because the
same argument is used twice.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-05-25 13:37:39 +02:00
parent b55f8abd29
commit b634a18a7f
14 changed files with 110 additions and 106 deletions

View File

@ -25,7 +25,7 @@ def make_log_file(log_dir, filename):
if not log_dir:
return None
ensure_dir(log_dir)
return os.path.join(log_dir, '{}.log'.format(filename))
return os.path.join(log_dir, '%s.log' % filename)
def init_ostree_repo(repo, log_dir=None):
@ -33,13 +33,13 @@ def init_ostree_repo(repo, log_dir=None):
log_file = make_log_file(log_dir, 'init-ostree-repo')
if not os.path.isdir(repo) or not os.listdir(repo):
ensure_dir(repo)
shortcuts.run(['ostree', 'init', '--repo={}'.format(repo), '--mode=archive-z2'],
shortcuts.run(['ostree', 'init', '--repo=%s' % repo, '--mode=archive-z2'],
show_cmd=True, stdout=True, logfile=log_file)
def make_ostree_repo(repo, config, log_dir=None):
log_file = make_log_file(log_dir, 'create-ostree-repo')
shortcuts.run(['rpm-ostree', 'compose', 'tree', '--repo={}'.format(repo), config],
shortcuts.run(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo, config],
show_cmd=True, stdout=True, logfile=log_file)

View File

@ -103,8 +103,8 @@ class ImageConfigMixin(object):
def get_config(self, cfg, opt):
return cfg.get(
opt, self.compose.conf.get(
'{}_{}'.format(self.name, opt), self.compose.conf.get(
'global_{}'.format(opt))))
'%s_%s' % (self.name, opt), self.compose.conf.get(
'global_%s' % opt)))
def get_release(self, cfg):
"""
@ -113,7 +113,7 @@ class ImageConfigMixin(object):
global settings.
"""
for key, conf in [('release', cfg),
('{}_release'.format(self.name), self.compose.conf),
('%s_release' % self.name, self.compose.conf),
('global_release', self.compose.conf)]:
if key in conf:
return conf[key] or self.compose.image_release
@ -126,7 +126,7 @@ class ImageConfigMixin(object):
"""
if 'ksurl' in cfg:
return util.resolve_git_url(cfg['ksurl'])
if '{}_ksurl'.format(self.name) in self.compose.conf:
if '%s_ksurl' % self.name in self.compose.conf:
return self.phase_ksurl
if 'global_ksurl' in self.compose.conf:
return self.global_ksurl
@ -137,7 +137,7 @@ class ImageConfigMixin(object):
"""Get phase level ksurl, making sure to resolve it only once."""
# The phase-level setting is cached as instance attribute of the phase.
if not self._phase_ksurl:
ksurl = self.compose.conf.get('{}_ksurl'.format(self.name))
ksurl = self.compose.conf.get('%s_ksurl' % self.name)
self._phase_ksurl = util.resolve_git_url(ksurl)
return self._phase_ksurl

View File

@ -127,16 +127,16 @@ class CreateisoPhase(PhaseBase):
cmd['cmd'] = [
'pungi-createiso',
'--output-dir={}'.format(iso_dir),
'--iso-name={}'.format(filename),
'--volid={}'.format(volid),
'--graft-points={}'.format(graft_points),
'--arch={}'.format(arch),
'--output-dir=%s' % iso_dir,
'--iso-name=%s' % filename,
'--volid=%s' % volid,
'--graft-points=%s' % graft_points,
'--arch=%s' % arch,
]
if bootable:
cmd['cmd'].append(
'--buildinstall-method={}'.format(self.compose.conf['buildinstall_method'])
'--buildinstall-method=%s' % self.compose.conf['buildinstall_method']
)
if self.compose.supported:
@ -145,8 +145,8 @@ class CreateisoPhase(PhaseBase):
if self.compose.conf.get('create_jigdo', True):
jigdo_dir = self.compose.paths.compose.jigdo_dir(arch, variant)
cmd['cmd'].extend([
'--jigdo-dir={}'.format(jigdo_dir),
'--os-tree={}'.format(os_tree),
'--jigdo-dir=%s' % jigdo_dir,
'--os-tree=%s' % os_tree,
])
commands.append((cmd, variant, arch))

View File

@ -67,8 +67,8 @@ class OSTreeThread(WorkerThread):
def _run_ostree_cmd(self, compose, variant, arch, config, config_repo):
cmd = [
'pungi-make-ostree',
'--log-dir={}'.format(os.path.join(self.logdir)),
'--treefile={}'.format(os.path.join(config_repo, config['treefile'])),
'--log-dir=%s' % os.path.join(self.logdir),
'--treefile=%s' % os.path.join(config_repo, config['treefile']),
config['ostree_repo']
]
@ -107,8 +107,8 @@ def tweak_file(path, source_repo):
"""
with open(path, 'r') as f:
contents = f.read()
replacement = 'baseurl={}'.format(source_repo)
contents = re.sub(r'^(mirrorlist|metalink|baseurl)=.*$',
replacement, contents, flags=re.MULTILINE)
replacement = 'baseurl=%s' % source_repo
exp = re.compile(r'^(mirrorlist|metalink|baseurl)=.*$', re.MULTILINE)
contents = exp.sub(replacement, contents)
with open(path, 'w') as f:
f.write(contents)

View File

@ -48,7 +48,7 @@ class OstreeInstallerThread(WorkerThread):
def worker(self, compose, variant, arch, config):
msg = 'Ostree phase for variant %s, arch %s' % (variant.uid, arch)
self.pool.log_info('[BEGIN] %s' % msg)
self.logdir = compose.paths.log.topdir('{}/ostree_installer'.format(arch))
self.logdir = compose.paths.log.topdir('%s/ostree_installer' % arch)
source_repo = self._get_source_repo(compose, arch, config['source_repo_from'])
output_dir = os.path.join(compose.paths.work.topdir(arch), variant.uid, 'ostree_installer')

View File

@ -456,10 +456,10 @@ def find_old_compose(old_compose_dirs, release_short, release_version,
def process_args(fmt, args):
"""Given a list of arguments, format each value with the format string.
>>> process_args('--opt={}', ['foo', 'bar'])
>>> process_args('--opt=%s', ['foo', 'bar'])
['--opt=foo', '--opt=bar']
"""
return [fmt.format(val) for val in force_list(args or [])]
return [fmt % val for val in force_list(args or [])]
@contextlib.contextmanager

View File

@ -58,11 +58,11 @@ class LoraxWrapper(object):
if volid:
cmd.append("--volid=%s" % volid)
cmd.extend(process_args('--installpkgs={}', buildinstallpackages))
cmd.extend(process_args('--add-template={}', add_template))
cmd.extend(process_args('--add-arch-template={}', add_arch_template))
cmd.extend(process_args('--add-template-var={}', add_template_var))
cmd.extend(process_args('--add-arch-template-var={}', add_arch_template_var))
cmd.extend(process_args('--installpkgs=%s', buildinstallpackages))
cmd.extend(process_args('--add-template=%s', add_template))
cmd.extend(process_args('--add-arch-template=%s', add_arch_template))
cmd.extend(process_args('--add-template-var=%s', add_template_var))
cmd.extend(process_args('--add-arch-template-var=%s', add_arch_template_var))
output_dir = os.path.abspath(output_dir)
cmd.append(output_dir)

View File

@ -96,15 +96,15 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
[mock.call((
compose,
{
'iso_path': '{}/compose/Server/x86_64/iso/image-name'.format(self.topdir),
'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
'bootable': False,
'cmd': ['pungi-createiso',
'--output-dir={}/compose/Server/x86_64/iso'.format(self.topdir),
'--output-dir=%s/compose/Server/x86_64/iso' % self.topdir,
'--iso-name=image-name', '--volid=test-1.0 Server.x86_64',
'--graft-points=dummy-graft-points',
'--arch=x86_64', '--supported',
'--jigdo-dir={}/compose/Server/x86_64/jigdo'.format(self.topdir),
'--os-tree={}/compose/Server/x86_64/os'.format(self.topdir)],
'--jigdo-dir=%s/compose/Server/x86_64/jigdo' % self.topdir,
'--os-tree=%s/compose/Server/x86_64/os' % self.topdir],
'label': '',
'disc_num': 1,
'disc_count': 1,
@ -157,32 +157,32 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
self.assertItemsEqual(
pool.queue_put.call_args_list,
[mock.call((compose,
{'iso_path': '{}/compose/Server/x86_64/iso/image-name'.format(self.topdir),
{'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
'bootable': True,
'cmd': ['pungi-createiso',
'--output-dir={}/compose/Server/x86_64/iso'.format(self.topdir),
'--output-dir=%s/compose/Server/x86_64/iso' % self.topdir,
'--iso-name=image-name', '--volid=test-1.0 Server.x86_64',
'--graft-points=dummy-graft-points',
'--arch=x86_64',
'--buildinstall-method=lorax',
'--supported',
'--jigdo-dir={}/compose/Server/x86_64/jigdo'.format(self.topdir),
'--os-tree={}/compose/Server/x86_64/os'.format(self.topdir)],
'--jigdo-dir=%s/compose/Server/x86_64/jigdo' % self.topdir,
'--os-tree=%s/compose/Server/x86_64/os' % self.topdir],
'label': '',
'disc_num': 1,
'disc_count': 1},
compose.variants['Server'],
'x86_64')),
mock.call((compose,
{'iso_path': '{}/compose/Server/source/iso/image-name'.format(self.topdir),
{'iso_path': '%s/compose/Server/source/iso/image-name' % self.topdir,
'bootable': False,
'cmd': ['pungi-createiso',
'--output-dir={}/compose/Server/source/iso'.format(self.topdir),
'--output-dir=%s/compose/Server/source/iso' % self.topdir,
'--iso-name=image-name', '--volid=test-1.0 Server.src',
'--graft-points=dummy-graft-points',
'--arch=src', '--supported',
'--jigdo-dir={}/compose/Server/source/jigdo'.format(self.topdir),
'--os-tree={}/compose/Server/source/tree'.format(self.topdir)],
'--jigdo-dir=%s/compose/Server/source/jigdo' % self.topdir,
'--os-tree=%s/compose/Server/source/tree' % self.topdir],
'label': '',
'disc_num': 1,
'disc_count': 1},
@ -207,7 +207,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
'koji_profile': 'koji',
})
cmd = {
'iso_path': '{}/compose/Server/x86_64/iso/image-name'.format(self.topdir),
'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
'bootable': False,
'cmd': mock.Mock(),
'label': '',
@ -233,14 +233,14 @@ class CreateisoThreadTest(helpers.PungiTestCase):
self.assertEqual(getTag.call_args_list, [mock.call('f25-build')])
self.assertEqual(get_runroot_cmd.call_args_list,
[mock.call('f25-build', 'x86_64', cmd['cmd'], channel=None,
mounts=['{}'.format(self.topdir)],
mounts=[self.topdir],
packages=['coreutils', 'genisoimage', 'isomd5sum',
'jigdo', 'pungi'],
task_id=True, use_shell=True)])
self.assertEqual(
run_runroot.call_args_list,
[mock.call(get_runroot_cmd.return_value,
log_file='{}/logs/x86_64/createiso-image-name.x86_64.log'.format(self.topdir))])
log_file='%s/logs/x86_64/createiso-image-name.x86_64.log' % self.topdir)])
self.assertEqual(IsoWrapper.return_value.get_implanted_md5.call_args_list,
[mock.call(cmd['iso_path'])])
self.assertEqual(IsoWrapper.return_value.get_volume_id.call_args_list,
@ -273,7 +273,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
'koji_profile': 'koji',
})
cmd = {
'iso_path': '{}/compose/Server/x86_64/iso/image-name'.format(self.topdir),
'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
'bootable': True,
'cmd': mock.Mock(),
'label': '',
@ -299,14 +299,14 @@ class CreateisoThreadTest(helpers.PungiTestCase):
self.assertEqual(getTag.call_args_list, [mock.call('f25-build')])
self.assertEqual(get_runroot_cmd.call_args_list,
[mock.call('f25-build', 'x86_64', cmd['cmd'], channel=None,
mounts=['{}'.format(self.topdir)],
mounts=[self.topdir],
packages=['coreutils', 'genisoimage', 'isomd5sum',
'jigdo', 'pungi', 'lorax'],
task_id=True, use_shell=True)])
self.assertEqual(
run_runroot.call_args_list,
[mock.call(get_runroot_cmd.return_value,
log_file='{}/logs/x86_64/createiso-image-name.x86_64.log'.format(self.topdir))])
log_file='%s/logs/x86_64/createiso-image-name.x86_64.log' % self.topdir)])
self.assertEqual(IsoWrapper.return_value.get_implanted_md5.call_args_list,
[mock.call(cmd['iso_path'])])
self.assertEqual(IsoWrapper.return_value.get_volume_id.call_args_list,
@ -340,7 +340,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
]
})
cmd = {
'iso_path': '{}/compose/Server/x86_64/iso/image-name'.format(self.topdir),
'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
'bootable': False,
'cmd': mock.Mock(),
'label': '',
@ -378,7 +378,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
]
})
cmd = {
'iso_path': '{}/compose/Server/x86_64/iso/image-name'.format(self.topdir),
'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
'bootable': False,
'cmd': mock.Mock(),
'label': '',
@ -400,8 +400,8 @@ class CreateisoThreadTest(helpers.PungiTestCase):
compose.log_info.assert_has_calls([
mock.call('[FAIL] Iso (variant Server, arch x86_64) failed, but going on anyway.'),
mock.call('Runroot task failed: 1234. See {} for more details.'.format(
self.topdir + '/logs/x86_64/createiso-image-name.x86_64.log'))
mock.call('Runroot task failed: 1234. See %s for more details.'
% (self.topdir + '/logs/x86_64/createiso-image-name.x86_64.log'))
])
@mock.patch('pungi.phases.createiso.IsoWrapper')
@ -417,7 +417,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
'runroot': False,
})
cmd = {
'iso_path': '{}/compose/Server/x86_64/iso/image-name'.format(self.topdir),
'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
'bootable': False,
'cmd': mock.Mock(),
'label': '',
@ -435,7 +435,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
self.assertEqual(
run.call_args_list,
[mock.call(cmd['cmd'], show_cmd=True,
logfile='{}/logs/x86_64/createiso-image-name.x86_64.log'.format(self.topdir))])
logfile='%s/logs/x86_64/createiso-image-name.x86_64.log' % self.topdir)])
self.assertEqual(IsoWrapper.return_value.get_implanted_md5.call_args_list,
[mock.call(cmd['iso_path'])])
self.assertEqual(IsoWrapper.return_value.get_volume_id.call_args_list,
@ -465,7 +465,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
]
})
cmd = {
'iso_path': '{}/compose/Server/x86_64/iso/image-name'.format(self.topdir),
'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
'bootable': False,
'cmd': mock.Mock(),
'label': '',

View File

@ -27,7 +27,7 @@ class CreateIsoScriptTest(helpers.PungiTestCase):
@mock.patch('kobo.shortcuts.run')
def test_minimal_run(self, run):
createiso.main([
'--output-dir={}'.format(self.outdir),
'--output-dir=%s' % self.outdir,
'--iso-name=DP-1.0-20160405.t.3-x86_64.iso',
'--volid=DP-1.0-20160405.t.3',
'--graft-points=graft-list',
@ -54,7 +54,7 @@ class CreateIsoScriptTest(helpers.PungiTestCase):
run.return_value = (0, '/usr/share/lorax')
createiso.main([
'--output-dir={}'.format(self.outdir),
'--output-dir=%s' % self.outdir,
'--iso-name=DP-1.0-20160405.t.3-x86_64.iso',
'--volid=DP-1.0-20160405.t.3',
'--graft-points=graft-list',
@ -93,7 +93,7 @@ class CreateIsoScriptTest(helpers.PungiTestCase):
run.return_value = (0, '/usr/share/lorax')
createiso.main([
'--output-dir={}'.format(self.outdir),
'--output-dir=%s' % self.outdir,
'--iso-name=DP-1.0-20160405.t.3-i386.iso',
'--volid=DP-1.0-20160405.t.3',
'--graft-points=graft-list',
@ -129,7 +129,7 @@ class CreateIsoScriptTest(helpers.PungiTestCase):
run.return_value = (0, '/usr/share/lorax')
createiso.main([
'--output-dir={}'.format(self.outdir),
'--output-dir=%s' % self.outdir,
'--iso-name=DP-1.0-20160405.t.3-ppc64.iso',
'--volid=DP-1.0-20160405.t.3',
'--graft-points=graft-list',
@ -161,7 +161,7 @@ class CreateIsoScriptTest(helpers.PungiTestCase):
@mock.patch('kobo.shortcuts.run')
def test_bootable_run_buildinstall(self, run):
createiso.main([
'--output-dir={}'.format(self.outdir),
'--output-dir=%s' % self.outdir,
'--iso-name=DP-1.0-20160405.t.3-ppc64.iso',
'--volid=DP-1.0-20160405.t.3',
'--graft-points=graft-list',
@ -194,24 +194,24 @@ class CreateIsoScriptTest(helpers.PungiTestCase):
def test_run_with_jigdo_bad_args(self, run, stderr):
with self.assertRaises(SystemExit):
createiso.main([
'--output-dir={}'.format(self.outdir),
'--output-dir=%s' % self.outdir,
'--iso-name=DP-1.0-20160405.t.3-x86_64.iso',
'--volid=DP-1.0-20160405.t.3',
'--graft-points=graft-list',
'--arch=x86_64',
'--jigdo-dir={}/jigdo'.format(self.topdir),
'--jigdo-dir=%s/jigdo' % self.topdir,
])
@mock.patch('kobo.shortcuts.run')
def test_run_with_jigdo(self, run):
createiso.main([
'--output-dir={}'.format(self.outdir),
'--output-dir=%s' % self.outdir,
'--iso-name=DP-1.0-20160405.t.3-x86_64.iso',
'--volid=DP-1.0-20160405.t.3',
'--graft-points=graft-list',
'--arch=x86_64',
'--jigdo-dir={}/jigdo'.format(self.topdir),
'--os-tree={}/os'.format(self.topdir),
'--jigdo-dir=%s/jigdo' % self.topdir,
'--os-tree=%s/os' % self.topdir,
])
self.maxDiff = None
self.assertItemsEqual(
@ -228,9 +228,9 @@ class CreateIsoScriptTest(helpers.PungiTestCase):
mock.call('isoinfo -R -f -i DP-1.0-20160405.t.3-x86_64.iso | grep -v \'/TRANS.TBL$\' | sort >> DP-1.0-20160405.t.3-x86_64.iso.manifest',
show_cmd=True, stdout=True, workdir=self.outdir),
mock.call(['jigdo-file', 'make-template', '--force',
'--image={}/isos/DP-1.0-20160405.t.3-x86_64.iso'.format(self.topdir),
'--jigdo={}/jigdo/DP-1.0-20160405.t.3-x86_64.iso.jigdo'.format(self.topdir),
'--template={}/jigdo/DP-1.0-20160405.t.3-x86_64.iso.template'.format(self.topdir),
'--image=%s/isos/DP-1.0-20160405.t.3-x86_64.iso' % self.topdir,
'--jigdo=%s/jigdo/DP-1.0-20160405.t.3-x86_64.iso.jigdo' % self.topdir,
'--template=%s/jigdo/DP-1.0-20160405.t.3-x86_64.iso.template' % self.topdir,
'--no-servers-section', '--report=noprogress', self.topdir + '/os//'],
show_cmd=True, stdout=True, workdir=self.outdir)]
)

View File

@ -558,16 +558,20 @@ class TestCreateImageBuildThread(PungiTestCase):
self.assertItemsEqual(
linker.mock_calls,
[mock.call('/koji/task/1235/Fedora-Docker-Base-20160103.amd64.qcow2',
[mock.call.link(
'/koji/task/1235/Fedora-Docker-Base-20160103.amd64.qcow2',
self.topdir + '/compose/Client/amd64/images/Fedora-Docker-Base-20160103.amd64.qcow2',
link_type='hardlink-or-copy'),
mock.call('/koji/task/1235/Fedora-Docker-Base-20160103.amd64.tar.xz',
mock.call.link(
'/koji/task/1235/Fedora-Docker-Base-20160103.amd64.tar.xz',
self.topdir + '/compose/Client/amd64/images/Fedora-Docker-Base-20160103.amd64.tar.xz',
link_type='hardlink-or-copy'),
mock.call('/koji/task/1235/Fedora-Docker-Base-20160103.x86_64.qcow2',
mock.call.link(
'/koji/task/1235/Fedora-Docker-Base-20160103.x86_64.qcow2',
self.topdir + '/compose/Client/x86_64/images/Fedora-Docker-Base-20160103.x86_64.qcow2',
link_type='hardlink-or-copy'),
mock.call('/koji/task/1235/Fedora-Docker-Base-20160103.x86_64.tar.xz',
mock.call.link(
'/koji/task/1235/Fedora-Docker-Base-20160103.x86_64.tar.xz',
self.topdir + '/compose/Client/x86_64/images/Fedora-Docker-Base-20160103.x86_64.tar.xz',
link_type='hardlink-or-copy')])

View File

@ -139,7 +139,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
'--product=Fedora',
'--version=Rawhide',
'--release=20160321.n.0',
'--source=file://{}/compose/Everything/x86_64/os'.format(self.topdir),
'--source=file://%s/compose/Everything/x86_64/os' % self.topdir,
'--variant=Everything',
'--nomacboot',
self.topdir + '/work/x86_64/Everything/ostree_installer'],
@ -314,11 +314,11 @@ class OstreeThreadTest(helpers.PungiTestCase):
'--product=Fedora',
'--version=Rawhide',
'--release=20160321.n.0',
'--source=file://{}/compose/Everything/x86_64/os'.format(self.topdir),
'--source=file://%s/compose/Everything/x86_64/os' % self.topdir,
'--variant=Everything',
'--nomacboot',
'--add-template={}/some_file.txt'.format(templ_dir),
'--add-arch-template={}/other_file.txt'.format(templ_dir),
'--add-template=%s/some_file.txt' % templ_dir,
'--add-arch-template=%s/other_file.txt' % templ_dir,
self.topdir + '/work/x86_64/Everything/ostree_installer'],
channel=None, mounts=[self.topdir],
packages=['pungi', 'lorax', 'ostree'],
@ -391,7 +391,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
['lorax',
'--product=Fedora',
'--version=Rawhide', '--release=20151203.t.0',
'--source=file://{}/compose/Everything/x86_64/os'.format(self.topdir),
'--source=file://%s/compose/Everything/x86_64/os' % self.topdir,
'--variant=Everything',
'--nomacboot',
'--installpkgs=fedora-productimg-atomic',

View File

@ -125,8 +125,8 @@ class OSTreeThreadTest(helpers.PungiTestCase):
self.assertEqual(koji.get_runroot_cmd.call_args_list,
[mock.call('rrt', 'x86_64',
['pungi-make-ostree',
'--log-dir={}/logs/x86_64/Everything/ostree-1'.format(self.topdir),
'--treefile={}/fedora-atomic-docker-host.json'.format(
'--log-dir=%s/logs/x86_64/Everything/ostree-1' % self.topdir,
'--treefile=%s/fedora-atomic-docker-host.json' % (
self.topdir + '/work/ostree-1/config_repo'),
self.repo],
channel=None, mounts=[self.topdir, self.repo],
@ -137,13 +137,13 @@ class OSTreeThreadTest(helpers.PungiTestCase):
log_file=self.topdir + '/logs/x86_64/Everything/ostree-1/runroot.log')])
with open(self.topdir + '/work/ostree-1/config_repo/fedora-rawhide.repo') as f:
self.assertIn('baseurl=http://example.com/Everything/x86_64/os'.format(self.topdir),
self.assertIn('baseurl=http://example.com/Everything/x86_64/os',
f.read())
with open(self.topdir + '/work/ostree-1/config_repo/fedora-24.repo') as f:
self.assertIn('baseurl=http://example.com/Everything/x86_64/os'.format(self.topdir),
self.assertIn('baseurl=http://example.com/Everything/x86_64/os',
f.read())
with open(self.topdir + '/work/ostree-1/config_repo/fedora-23.repo') as f:
self.assertIn('baseurl=http://example.com/Everything/x86_64/os'.format(self.topdir),
self.assertIn('baseurl=http://example.com/Everything/x86_64/os',
f.read())
self.assertTrue(os.path.isdir(self.repo))
@ -180,8 +180,8 @@ class OSTreeThreadTest(helpers.PungiTestCase):
compose.log_info.assert_has_calls([
mock.call('[FAIL] Ostree (variant Everything, arch x86_64) failed, but going on anyway.'),
mock.call('Runroot task failed: 1234. See {} for more details.'.format(
self.topdir + '/logs/x86_64/Everything/ostree-1/runroot.log'))
mock.call('Runroot task failed: 1234. See %s for more details.'
% (self.topdir + '/logs/x86_64/Everything/ostree-1/runroot.log'))
])
@mock.patch('pungi.wrappers.scm.get_dir_from_scm')

View File

@ -22,17 +22,17 @@ class OstreeScriptTest(helpers.PungiTestCase):
repo = os.path.join(self.topdir, 'atomic')
ostree.main([
'--log-dir={}'.format(os.path.join(self.topdir, 'logs', 'Atomic')),
'--treefile={}/fedora-atomic-docker-host.json'.format(self.topdir),
'--log-dir=%s' % os.path.join(self.topdir, 'logs', 'Atomic'),
'--treefile=%s/fedora-atomic-docker-host.json' % self.topdir,
repo,
])
self.maxDiff = None
self.assertItemsEqual(
run.call_args_list,
[mock.call(['ostree', 'init', '--repo={}'.format(repo), '--mode=archive-z2'],
[mock.call(['ostree', 'init', '--repo=%s' % repo, '--mode=archive-z2'],
logfile=self.topdir + '/logs/Atomic/init-ostree-repo.log', show_cmd=True, stdout=True),
mock.call(['rpm-ostree', 'compose', 'tree', '--repo={}'.format(repo),
mock.call(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo,
self.topdir + '/fedora-atomic-docker-host.json'],
logfile=self.topdir + '/logs/Atomic/create-ostree-repo.log', show_cmd=True, stdout=True)])
@ -43,17 +43,17 @@ class OstreeScriptTest(helpers.PungiTestCase):
os.mkdir(repo)
ostree.main([
'--log-dir={}'.format(os.path.join(self.topdir, 'logs', 'Atomic')),
'--treefile={}/fedora-atomic-docker-host.json'.format(self.topdir),
'--log-dir=%s' % os.path.join(self.topdir, 'logs', 'Atomic'),
'--treefile=%s/fedora-atomic-docker-host.json' % self.topdir,
repo,
])
self.maxDiff = None
self.assertItemsEqual(
run.call_args_list,
[mock.call(['ostree', 'init', '--repo={}'.format(repo), '--mode=archive-z2'],
[mock.call(['ostree', 'init', '--repo=%s' % repo, '--mode=archive-z2'],
logfile=self.topdir + '/logs/Atomic/init-ostree-repo.log', show_cmd=True, stdout=True),
mock.call(['rpm-ostree', 'compose', 'tree', '--repo={}'.format(repo),
mock.call(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo,
self.topdir + '/fedora-atomic-docker-host.json'],
logfile=self.topdir + '/logs/Atomic/create-ostree-repo.log', show_cmd=True, stdout=True)])
@ -64,15 +64,15 @@ class OstreeScriptTest(helpers.PungiTestCase):
helpers.touch(os.path.join(repo, 'initialized'))
ostree.main([
'--log-dir={}'.format(os.path.join(self.topdir, 'logs', 'Atomic')),
'--treefile={}/fedora-atomic-docker-host.json'.format(self.topdir),
'--log-dir=%s' % os.path.join(self.topdir, 'logs', 'Atomic'),
'--treefile=%s/fedora-atomic-docker-host.json' % self.topdir,
repo,
])
self.maxDiff = None
self.assertItemsEqual(
run.call_args_list,
[mock.call(['rpm-ostree', 'compose', 'tree', '--repo={}'.format(repo),
[mock.call(['rpm-ostree', 'compose', 'tree', '--repo=%s' % repo,
self.topdir + '/fedora-atomic-docker-host.json'],
logfile=self.topdir + '/logs/Atomic/create-ostree-repo.log', show_cmd=True, stdout=True)])

View File

@ -204,11 +204,11 @@ class TestFindOldCompose(unittest.TestCase):
class TestHelpers(PungiTestCase):
def test_process_args(self):
self.assertEqual(util.process_args('--opt={}', None), [])
self.assertEqual(util.process_args('--opt={}', []), [])
self.assertEqual(util.process_args('--opt={}', ['foo', 'bar']),
self.assertEqual(util.process_args('--opt=%s', None), [])
self.assertEqual(util.process_args('--opt=%s', []), [])
self.assertEqual(util.process_args('--opt=%s', ['foo', 'bar']),
['--opt=foo', '--opt=bar'])
self.assertEqual(util.process_args('--opt={}', 'foo'), ['--opt=foo'])
self.assertEqual(util.process_args('--opt=%s', 'foo'), ['--opt=foo'])
def test_makedirs(self):
util.makedirs(self.topdir + '/foo/bar/baz')