Convert configparser values to string

On Python 3, configparser will reject non string values, and
theoretically we could have some in the configuration.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-09-19 09:59:23 +02:00
parent 2efc4d8561
commit 797b13b34a
2 changed files with 7 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import contextlib
import koji import koji
from kobo.shortcuts import run from kobo.shortcuts import run
import six
from six.moves import configparser from six.moves import configparser
from .. import util from .. import util
@ -171,6 +172,9 @@ class KojiWrapper(object):
for section, opts in config_options.items(): for section, opts in config_options.items():
cfg_parser.add_section(section) cfg_parser.add_section(section)
for option, value in opts.items(): for option, value in opts.items():
if not isinstance(value, six.string_types):
# Python 3 configparser will reject non-string values.
value = str(value)
cfg_parser.set(section, option, value) cfg_parser.set(section, option, value)
fd = open(conf_file_dest, "w") fd = open(conf_file_dest, "w")

View File

@ -83,6 +83,7 @@ class KojiWrapperTest(KojiWrapperBaseTestCase):
'ksurl': 'git://example.com/ks.git', 'ksurl': 'git://example.com/ks.git',
'distro': 'test-distro', 'distro': 'test-distro',
'release': '20160222.0', 'release': '20160222.0',
'disk_size': 4,
} }
}, },
self.tmpfile self.tmpfile
@ -105,7 +106,8 @@ class KojiWrapperTest(KojiWrapperBaseTestCase):
'kickstart = test-kickstart', 'kickstart = test-kickstart',
'ksurl = git://example.com/ks.git', 'ksurl = git://example.com/ks.git',
'distro = test-distro', 'distro = test-distro',
'release = 20160222.0']) 'release = 20160222.0',
'disk_size = 4'])
def test_get_image_paths(self): def test_get_image_paths(self):