diff -r 3337298f5c75 Lib/test/test_xpickle.py --- a/Lib/test/test_xpickle.py Tue Dec 10 17:23:00 2013 +0100 +++ b/Lib/test/test_xpickle.py Tue Dec 10 11:14:24 2013 -0600 @@ -68,7 +68,7 @@ Returns: True if the name is valid, False otherwise. """ - return os.system(name + " -c 'import test.test_support'") == 0 + return os.system(name + ' -c "import test.test_support"') == 0 class AbstractCompatTests(AbstractPickleTests): @@ -119,14 +119,7 @@ # These tests are disabled because they require some special setup # on the worker that's hard to keep in sync. - def test_global_ext1(self): - pass - - def test_global_ext2(self): - pass - - def test_global_ext4(self): - pass + test_global_ext1 = test_global_ext2 = test_global_ext4 = None # This is a cut-down version of pickletester's test_float. Backwards # compatibility for the values in for_bin_protos was explicitly broken in @@ -151,48 +144,42 @@ self.assertEqual(value, got) # Backwards compatibility was explicitly broken in r67934 to fix a bug. - def test_unicode_high_plane(self): - pass + test_unicode_high_plane = None # This tests a fix that's in 2.7 only - def test_dynamic_class(self): - pass + test_dynamic_class = None - if test_support.have_unicode: - # This is a cut-down version of pickletester's test_unicode. Backwards - # compatibility was explicitly broken in r67934 to fix a bug. - def test_unicode(self): - endcases = [u'', u'<\\u>', u'<\\\u1234>', u'<\n>', u'<\\>'] - for proto in pickletester.protocols: - for u in endcases: - p = self.dumps(u, proto) - u2 = self.loads(p) - self.assertEqual(u2, u) + # This is a cut-down version of pickletester's test_unicode. Backwards + # compatibility was explicitly broken in r67934 to fix a bug. + @unittest.skipUnless(test_support.have_unicode, 'no unicode support') + def test_unicode(self): + endcases = [u'', u'<\\u>', u'<\\\u1234>', u'<\n>', u'<\\>'] + for proto in pickletester.protocols: + for u in endcases: + p = self.dumps(u, proto) + u2 = self.loads(p) + self.assertEqual(u2, u) -def run_compat_test(python_name): - return (test_support.is_resource_enabled("xpickle") and - have_python_version(python_name)) +def compat_test(python_name): + def decorator(func): + if have_python_version(python_name): + return test_support.requires_resource("xpickle")(func) + return unittest.skip('%s not available' % python_name)(func) + return decorator # Test backwards compatibility with Python 2.4. -if not run_compat_test("python2.4"): - class CPicklePython24Compat(unittest.TestCase): - pass -else: - class CPicklePython24Compat(AbstractCompatTests): +@compat_test("python2.4") +class CPicklePython24Compat(AbstractCompatTests): - module = cPickle - python = "python2.4" - error = cPickle.BadPickleGet + module = cPickle + python = "python2.4" + error = cPickle.BadPickleGet - # Disable these tests for Python 2.4. Making them pass would require - # nontrivially monkeypatching the pickletester module in the worker. - def test_reduce_calls_base(self): - pass - - def test_reduce_ex_calls_base(self): - pass + # Disable these tests for Python 2.4. Making them pass would require + # nontrivially monkeypatching the pickletester module in the worker. + test_reduce_calls_base = test_reduce_ex_calls_base = None class PicklePython24Compat(CPicklePython24Compat): @@ -201,15 +188,12 @@ # Test backwards compatibility with Python 2.5. -if not run_compat_test("python2.5"): - class CPicklePython25Compat(unittest.TestCase): - pass -else: - class CPicklePython25Compat(AbstractCompatTests): +@compat_test("python2.5") +class CPicklePython25Compat(AbstractCompatTests): - module = cPickle - python = "python2.5" - error = cPickle.BadPickleGet + module = cPickle + python = "python2.5" + error = cPickle.BadPickleGet class PicklePython25Compat(CPicklePython25Compat): @@ -218,15 +202,12 @@ # Test backwards compatibility with Python 2.6. -if not run_compat_test("python2.6"): - class CPicklePython26Compat(unittest.TestCase): - pass -else: - class CPicklePython26Compat(AbstractCompatTests): +@compat_test("python2.6") +class CPicklePython26Compat(AbstractCompatTests): - module = cPickle - python = "python2.6" - error = cPickle.BadPickleGet + module = cPickle + python = "python2.6" + error = cPickle.BadPickleGet class PicklePython26Compat(CPicklePython26Compat): @@ -241,11 +222,6 @@ def test_main(): - if not test_support.is_resource_enabled("xpickle"): - print >>sys.stderr, "test_xpickle -- skipping backwards compat tests." - print >>sys.stderr, "Use 'regrtest.py -u xpickle' to run them." - sys.stderr.flush() - test_support.run_unittest( DumpCPickle_LoadPickle, DumpPickle_LoadCPickle,