1
0
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:
Daniel Mach 2023-11-15 09:14:52 +01:00
parent 526adc345a
commit 69a68b06b3
2 changed files with 18 additions and 1 deletions

View File

@ -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)

View File

@ -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()