diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-10-21 21:47:32 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-10-21 21:47:32 +0100 |
| commit | 1feb179fba9a569731d047ae2d4de848e35fc58f (patch) | |
| tree | 584a09d12c98a2c2b03b1672e858e8952b4b388e /tests/test_dates.py | |
| parent | a33c0670fd1d6e3f5b9fbec20fef8e9e835b67a7 (diff) | |
| download | psycopg2-1feb179fba9a569731d047ae2d4de848e35fc58f.tar.gz | |
Fixed pickling of FixedOffsetTimezone objects
I have also verified that the fixed class can unpickle instance pickled with
the buggy one and viceversa.
Fixes ticket #135.
Diffstat (limited to 'tests/test_dates.py')
| -rwxr-xr-x | tests/test_dates.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_dates.py b/tests/test_dates.py index 9be68a2..0d18f66 100755 --- a/tests/test_dates.py +++ b/tests/test_dates.py @@ -539,6 +539,24 @@ class FixedOffsetTimezoneTests(unittest.TestCase): self.assert_(FixedOffsetTimezone(9 * 60) is not FixedOffsetTimezone(9 * 60, 'FOO')) self.assert_(FixedOffsetTimezone(name='FOO') is not FixedOffsetTimezone(9 * 60, 'FOO')) + def test_pickle(self): + # ticket #135 + import pickle + + tz11 = FixedOffsetTimezone(60) + tz12 = FixedOffsetTimezone(120) + for proto in [-1, 0, 1, 2]: + tz21, tz22 = pickle.loads(pickle.dumps([tz11, tz12], proto)) + self.assertEqual(tz11, tz21) + self.assertEqual(tz12, tz22) + + tz11 = FixedOffsetTimezone(60, name='foo') + tz12 = FixedOffsetTimezone(120, name='bar') + for proto in [-1, 0, 1, 2]: + tz21, tz22 = pickle.loads(pickle.dumps([tz11, tz12], proto)) + self.assertEqual(tz11, tz21) + self.assertEqual(tz12, tz22) + def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__) |
