mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 14:56:14 +01:00
Merge pull request #1446 from dmach/configparser-replace-readfp-with-read_file
Fix conf.write_initial_config() to use read_file() instead of deprecated readfp()
This commit is contained in:
commit
ddc7b24b90
3
.github/workflows/build-install.yaml
vendored
3
.github/workflows/build-install.yaml
vendored
@ -27,7 +27,8 @@ jobs:
|
|||||||
container:
|
container:
|
||||||
|
|
||||||
# Fedora
|
# Fedora
|
||||||
- 'registry.fedoraproject.org/fedora:36'
|
- 'registry.fedoraproject.org/fedora:38'
|
||||||
|
- 'registry.fedoraproject.org/fedora:39'
|
||||||
- 'registry.fedoraproject.org/fedora:rawhide'
|
- 'registry.fedoraproject.org/fedora:rawhide'
|
||||||
|
|
||||||
# OpenSUSE
|
# OpenSUSE
|
||||||
|
3
.github/workflows/tests.yaml
vendored
3
.github/workflows/tests.yaml
vendored
@ -26,7 +26,8 @@ jobs:
|
|||||||
container:
|
container:
|
||||||
|
|
||||||
# Fedora
|
# Fedora
|
||||||
- 'registry.fedoraproject.org/fedora:36'
|
- 'registry.fedoraproject.org/fedora:38'
|
||||||
|
- 'registry.fedoraproject.org/fedora:39'
|
||||||
- 'registry.fedoraproject.org/fedora:rawhide'
|
- 'registry.fedoraproject.org/fedora:rawhide'
|
||||||
|
|
||||||
# openSUSE
|
# openSUSE
|
||||||
|
@ -1716,7 +1716,7 @@ def write_initial_config(conffile, entries, custom_template='', creds_mgr_descri
|
|||||||
config.update(entries)
|
config.update(entries)
|
||||||
sio = StringIO(conf_template.strip() % config)
|
sio = StringIO(conf_template.strip() % config)
|
||||||
cp = OscConfigParser.OscConfigParser()
|
cp = OscConfigParser.OscConfigParser()
|
||||||
cp.readfp(sio)
|
cp.read_file(sio)
|
||||||
cp.set(config['apiurl'], 'user', config['user'])
|
cp.set(config['apiurl'], 'user', config['user'])
|
||||||
if creds_mgr_descriptor:
|
if creds_mgr_descriptor:
|
||||||
creds_mgr = creds_mgr_descriptor.create(cp)
|
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")
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user