Skip to content

Commit

Permalink
Merge pull request #1446 from dmach/configparser-replace-readfp-with-…
Browse files Browse the repository at this point in the history
…read_file

Fix conf.write_initial_config() to use read_file() instead of deprecated readfp()
  • Loading branch information
dmach authored Nov 15, 2023
2 parents 503cf10 + 69a68b0 commit ddc7b24
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ jobs:
container:

# Fedora
- 'registry.fedoraproject.org/fedora:36'
- 'registry.fedoraproject.org/fedora:38'
- 'registry.fedoraproject.org/fedora:39'
- 'registry.fedoraproject.org/fedora:rawhide'

# OpenSUSE
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
container:

# Fedora
- 'registry.fedoraproject.org/fedora:36'
- 'registry.fedoraproject.org/fedora:38'
- 'registry.fedoraproject.org/fedora:39'
- 'registry.fedoraproject.org/fedora:rawhide'

# openSUSE
Expand Down
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 ddc7b24

Please sign in to comment.