diff options
author | Anthony Baxter <anthonybaxter@gmail.com> | 2005-09-20 15:17:16 (GMT) |
---|---|---|
committer | Anthony Baxter <anthonybaxter@gmail.com> | 2005-09-20 15:17:16 (GMT) |
commit | 523263d4436dc025db66be5b4e40ae3f26050ee9 (patch) | |
tree | 90ab13d57f575d335666eb582ee8a80f86a297de | |
parent | d8b9721d0debee0c26fd42bdae64da7896f7f443 (diff) | |
download | cpython-523263d4436dc025db66be5b4e40ae3f26050ee9.zip cpython-523263d4436dc025db66be5b4e40ae3f26050ee9.tar.gz cpython-523263d4436dc025db66be5b4e40ae3f26050ee9.tar.bz2 |
backport:
test_default_encoding_issues(): Fully restore sys.setdefaultencoding.
test_site often failed under "regrtest.py -r", because this xmlrpc test
left sys with a setdefaultencoding attribute, but loading site.py removes
that attribute and test_site.py verifies the attribute is gone. Changed
this test to get rid of sys.setdefaultencoding if it didn't exist when
this test started.
-rw-r--r-- | Lib/test/test_xmlrpc.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py index 3a4d808..31fb4d9 100644 --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -63,13 +63,20 @@ class XMLRPCTestCase(unittest.TestCase): </value></param> </params> """ + + # sys.setdefaultencoding() normally doesn't exist after site.py is + # loaded. reload(sys) is the way to get it back. old_encoding = sys.getdefaultencoding() + setdefaultencoding_existed = hasattr(sys, "setdefaultencoding") reload(sys) # ugh! sys.setdefaultencoding("iso-8859-1") try: (s, d), m = xmlrpclib.loads(utf8) finally: sys.setdefaultencoding(old_encoding) + if not setdefaultencoding_existed: + del sys.setdefaultencoding + items = d.items() if have_unicode: self.assertEquals(s, u"abc \x95") |