diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-15 12:06:02 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-12-15 12:06:02 (GMT) |
commit | 65ee4674e290ba893509f51f192dd1c9aa3a0422 (patch) | |
tree | c1e960162df4444ff18a2ad3aff11d713ef9ea12 /Lib/ctypes | |
parent | 0e32ea1089059a15b04a40c43bfe671e38ae16e7 (diff) | |
parent | bad1257c96943dcb39584a41e1a178542479df97 (diff) | |
download | cpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.zip cpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.tar.gz cpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.tar.bz2 |
Issue #22777: Test pickling with all protocols.
Diffstat (limited to 'Lib/ctypes')
-rw-r--r-- | Lib/ctypes/test/test_pickling.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Lib/ctypes/test/test_pickling.py b/Lib/ctypes/test/test_pickling.py index 8c91222..c4a79b9 100644 --- a/Lib/ctypes/test/test_pickling.py +++ b/Lib/ctypes/test/test_pickling.py @@ -14,9 +14,9 @@ class X(Structure): class Y(X): _fields_ = [("str", c_char_p)] -class PickleTest(unittest.TestCase): +class PickleTest: def dumps(self, item): - return pickle.dumps(item) + return pickle.dumps(item, self.proto) def loads(self, item): return pickle.loads(item) @@ -67,17 +67,15 @@ class PickleTest(unittest.TestCase): self.assertRaises(ValueError, lambda: self.dumps(item)) def test_wchar(self): - pickle.dumps(c_char(b"x")) + self.dumps(c_char(b"x")) # Issue 5049 - pickle.dumps(c_wchar("x")) + self.dumps(c_wchar("x")) -class PickleTest_1(PickleTest): - def dumps(self, item): - return pickle.dumps(item, 1) - -class PickleTest_2(PickleTest): - def dumps(self, item): - return pickle.dumps(item, 2) +for proto in range(pickle.HIGHEST_PROTOCOL + 1): + name = 'PickleTest_%s' % proto + globals()[name] = type(name, + (PickleTest, unittest.TestCase), + {'proto': proto}) if __name__ == "__main__": unittest.main() |