Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility issues with Python 3.11 #24

Merged
merged 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions tests/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ def test_basic(self):
eq(cf.get('Spaces', 'key with spaces'), 'value')
eq(cf.get('Spaces', 'another with spaces'), 'splat!')

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

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

Expand All @@ -127,10 +127,10 @@ def test_case_sensitivity(self):
eq(cf.options("a"), ["b"])
eq(cf.get("a", "b"), "value",
"could not locate option, expecting case-insensitive option names")
self.failUnless(cf.has_option("a", "b"))
self.assertTrue(cf.has_option("a", "b"))
cf.set("A", "A-B", "A-B value")
for opt in ("a-b", "A-b", "a-B", "A-B"):
self.failUnless(
self.assertTrue(
cf.has_option("A", opt),
"has_option() returned false for option which should exist")
eq(cf.options("A"), ["a-b"])
Expand All @@ -147,7 +147,7 @@ def test_case_sensitivity(self):
# SF bug #561822:
cf = self.fromstring("[section]\nnekey=nevalue\n",
defaults={"key":"value"})
self.failUnless(cf.has_option("section", "Key"))
self.assertTrue(cf.has_option("section", "Key"))

def test_default_case_sensitivity(self):
cf = self.newconfig({"foo": "Bar"})
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_query_errors(self):
cf = self.newconfig()
self.assertEqual(cf.sections(), [],
"new ConfigParser should have no defined sections")
self.failIf(cf.has_section("Foo"),
self.assertFalse(cf.has_section("Foo"),
"new ConfigParser should have no acknowledged sections")
self.assertRaises(ConfigParser.NoSectionError,
cf.options, "Foo")
Expand Down Expand Up @@ -221,8 +221,8 @@ def test_boolean(self):
"E5=FALSE AND MORE"
)
for x in range(1, 5):
self.failUnless(cf.getboolean('BOOLTEST', 't%d' % x))
self.failIf(cf.getboolean('BOOLTEST', 'f%d' % x))
self.assertTrue(cf.getboolean('BOOLTEST', 't%d' % x))
self.assertFalse(cf.getboolean('BOOLTEST', 'f%d' % x))
self.assertRaises(ValueError,
cf.getboolean, 'BOOLTEST', 'e%d' % x)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_fuzz(self):
cc = compat.RawConfigParser()
cc.readfp(StringIO(s))
cc_py = configparser.RawConfigParser()
cc_py.readfp(StringIO(s))
cc_py.read_file(StringIO(s))
# compare the two configparsers
self.assertEqualConfig(cc_py, cc)
# check that tidy does not change semantics
Expand Down