diff options
author | Tim Peters <tim.peters@gmail.com> | 2005-04-08 18:00:59 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2005-04-08 18:00:59 (GMT) |
commit | f754f5fd68d5ab4f6f7077dcc90080857f5e7e85 (patch) | |
tree | 6c55f0a2a8321a24de3e72b3f40c34d793ad1c07 /Lib | |
parent | b53b741171a422adac23dd97e58e3cb970aa5888 (diff) | |
download | cpython-f754f5fd68d5ab4f6f7077dcc90080857f5e7e85.zip cpython-f754f5fd68d5ab4f6f7077dcc90080857f5e7e85.tar.gz cpython-f754f5fd68d5ab4f6f7077dcc90080857f5e7e85.tar.bz2 |
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.
Don't know whether this is a bugfix (backport) candidate.
Diffstat (limited to 'Lib')
-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 b80de18..df0893d 100644 --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -80,13 +80,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") |