mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-11 16:36:14 +01:00
Fix conf.write_initial_config() to use read_file() instead of deprecated readfp()
This commit is contained in:
parent
526adc345a
commit
69a68b06b3
@ -1716,7 +1716,7 @@ def write_initial_config(conffile, entries, custom_template='', creds_mgr_descri
|
||||
config.update(entries)
|
||||
sio = StringIO(conf_template.strip() % config)
|
||||
cp = OscConfigParser.OscConfigParser()
|
||||
cp.readfp(sio)
|
||||
cp.read_file(sio)
|
||||
cp.set(config['apiurl'], 'user', config['user'])
|
||||
if creds_mgr_descriptor:
|
||||
creds_mgr = creds_mgr_descriptor.create(cp)
|
||||
|
@ -469,5 +469,22 @@ class TestFromParent(unittest.TestCase):
|
||||
self.assertEqual(self.host_options.email, "another-user@example.com")
|
||||
|
||||
|
||||
class TestConf(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmpdir = tempfile.mkdtemp(prefix="osc_test_")
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmpdir)
|
||||
|
||||
def test_write_initial_config(self):
|
||||
conffile = os.path.join(self.tmpdir, "oscrc")
|
||||
entries = {
|
||||
"user": "Admin",
|
||||
"pass": "opensuse",
|
||||
"apiurl": "https://example.com",
|
||||
}
|
||||
osc.conf.write_initial_config(conffile, entries)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user