Skip to content

Commit d9a083b

Browse files
committed
Fix compatibility issues with Python 3.11
* Fixes: #23 * BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2019017 * Replaced few deprecated methods with new methods
1 parent fd552cc commit d9a083b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

tests/test_compat.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ def test_basic(self):
9696
eq(cf.get('Spaces', 'key with spaces'), 'value')
9797
eq(cf.get('Spaces', 'another with spaces'), 'splat!')
9898

99-
self.failIf('__name__' in cf.options("Foo Bar"),
99+
self.assertFalse('__name__' in cf.options("Foo Bar"),
100100
'__name__ "option" should not be exposed by the API!')
101101

102102
# Make sure the right things happen for remove_option();
103103
# added to include check for SourceForge bug #123324:
104-
self.failUnless(cf.remove_option('Foo Bar', 'foo'),
104+
self.assertTrue(cf.remove_option('Foo Bar', 'foo'),
105105
"remove_option() failed to report existance of option")
106-
self.failIf(cf.has_option('Foo Bar', 'foo'),
106+
self.assertFalse(cf.has_option('Foo Bar', 'foo'),
107107
"remove_option() failed to remove option")
108-
self.failIf(cf.remove_option('Foo Bar', 'foo'),
108+
self.assertFalse(cf.remove_option('Foo Bar', 'foo'),
109109
"remove_option() failed to report non-existance of option"
110110
" that was removed")
111111

@@ -127,10 +127,10 @@ def test_case_sensitivity(self):
127127
eq(cf.options("a"), ["b"])
128128
eq(cf.get("a", "b"), "value",
129129
"could not locate option, expecting case-insensitive option names")
130-
self.failUnless(cf.has_option("a", "b"))
130+
self.assertTrue(cf.has_option("a", "b"))
131131
cf.set("A", "A-B", "A-B value")
132132
for opt in ("a-b", "A-b", "a-B", "A-B"):
133-
self.failUnless(
133+
self.assertTrue(
134134
cf.has_option("A", opt),
135135
"has_option() returned false for option which should exist")
136136
eq(cf.options("A"), ["a-b"])
@@ -147,7 +147,7 @@ def test_case_sensitivity(self):
147147
# SF bug #561822:
148148
cf = self.fromstring("[section]\nnekey=nevalue\n",
149149
defaults={"key":"value"})
150-
self.failUnless(cf.has_option("section", "Key"))
150+
self.assertTrue(cf.has_option("section", "Key"))
151151

152152
def test_default_case_sensitivity(self):
153153
cf = self.newconfig({"foo": "Bar"})
@@ -182,7 +182,7 @@ def test_query_errors(self):
182182
cf = self.newconfig()
183183
self.assertEqual(cf.sections(), [],
184184
"new ConfigParser should have no defined sections")
185-
self.failIf(cf.has_section("Foo"),
185+
self.assertFalse(cf.has_section("Foo"),
186186
"new ConfigParser should have no acknowledged sections")
187187
self.assertRaises(ConfigParser.NoSectionError,
188188
cf.options, "Foo")
@@ -221,8 +221,8 @@ def test_boolean(self):
221221
"E5=FALSE AND MORE"
222222
)
223223
for x in range(1, 5):
224-
self.failUnless(cf.getboolean('BOOLTEST', 't%d' % x))
225-
self.failIf(cf.getboolean('BOOLTEST', 'f%d' % x))
224+
self.assertTrue(cf.getboolean('BOOLTEST', 't%d' % x))
225+
self.assertFalse(cf.getboolean('BOOLTEST', 'f%d' % x))
226226
self.assertRaises(ValueError,
227227
cf.getboolean, 'BOOLTEST', 'e%d' % x)
228228

tests/test_fuzz.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_fuzz(self):
102102
cc = compat.RawConfigParser()
103103
cc.readfp(StringIO(s))
104104
cc_py = configparser.RawConfigParser()
105-
cc_py.readfp(StringIO(s))
105+
cc_py.read_file(StringIO(s))
106106
# compare the two configparsers
107107
self.assertEqualConfig(cc_py, cc)
108108
# check that tidy does not change semantics

0 commit comments

Comments
 (0)