1
0
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:
Daniel Mach 2023-11-15 09:36:38 +01:00 committed by GitHub
commit ddc7b24b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 3 deletions

View File

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

View File

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

View File

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

View File

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