Skip to content

Commit

Permalink
Fix conf.write_initial_config() to use read_file() instead of depreca…
Browse files Browse the repository at this point in the history
…ted readfp()
  • Loading branch information
dmach committed Nov 15, 2023
1 parent 526adc3 commit 69a68b0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion osc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,5 +469,22 @@ def test_email(self):
self.assertEqual(self.host_options.email, "[email protected]")


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

0 comments on commit 69a68b0

Please sign in to comment.