Commit 1e939e34 authored by Victor Stinner's avatar Victor Stinner

Issue #19424: Fix test_warnings for locale encoding unable to encode

"\xe9\u20ac" characters
parent a9593248
...@@ -336,12 +336,13 @@ class WarnTests(BaseTest): ...@@ -336,12 +336,13 @@ class WarnTests(BaseTest):
module=self.module) as w: module=self.module) as w:
self.module.resetwarnings() self.module.resetwarnings()
self.module.filterwarnings("always", category=UserWarning) self.module.filterwarnings("always", category=UserWarning)
for filename in ("nonascii\xe9\u20ac", "surrogate\udc80"):
self.module.warn_explicit("text", UserWarning, "nonascii\xe9\u20ac", 1) try:
self.assertEqual(w[-1].filename, "nonascii\xe9\u20ac") os.fsencode(filename)
except UnicodeEncodeError:
self.module.warn_explicit("text", UserWarning, "surrogate\udc80", 1) continue
self.assertEqual(w[-1].filename, "surrogate\udc80") self.module.warn_explicit("text", UserWarning, filename, 1)
self.assertEqual(w[-1].filename, filename)
def test_warn_explicit_type_errors(self): def test_warn_explicit_type_errors(self):
# warn_explicit() should error out gracefully if it is given objects # warn_explicit() should error out gracefully if it is given objects
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment