diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-10-29 22:58:05 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-10-29 22:58:05 (GMT) |
commit | c0e07a3ea00ee94618fc51072aeda27f7d7c3d25 (patch) | |
tree | da97f05276f5816f70385b2f7935888845b67272 /Lib | |
parent | a4c704b260cc9c020d19f8417cb4524a19d0e90c (diff) | |
download | cpython-c0e07a3ea00ee94618fc51072aeda27f7d7c3d25.zip cpython-c0e07a3ea00ee94618fc51072aeda27f7d7c3d25.tar.gz cpython-c0e07a3ea00ee94618fc51072aeda27f7d7c3d25.tar.bz2 |
Issue #19424: Fix test_warnings for locale encoding unable to encode
"\xe9\u20ac" characters
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_warnings.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index 52bbaf9..13c7df1 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -336,12 +336,13 @@ class WarnTests(BaseTest): module=self.module) as w: self.module.resetwarnings() self.module.filterwarnings("always", category=UserWarning) - - self.module.warn_explicit("text", UserWarning, "nonascii\xe9\u20ac", 1) - self.assertEqual(w[-1].filename, "nonascii\xe9\u20ac") - - self.module.warn_explicit("text", UserWarning, "surrogate\udc80", 1) - self.assertEqual(w[-1].filename, "surrogate\udc80") + for filename in ("nonascii\xe9\u20ac", "surrogate\udc80"): + try: + os.fsencode(filename) + except UnicodeEncodeError: + continue + self.module.warn_explicit("text", UserWarning, filename, 1) + self.assertEqual(w[-1].filename, filename) def test_warn_explicit_type_errors(self): # warn_explicit() should error out gracefully if it is given objects |