|
3 | 3 | See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases |
4 | 4 | """ |
5 | 5 |
|
| 6 | +import copy |
6 | 7 | import sys |
7 | 8 | import pickle |
8 | 9 | import random |
@@ -223,7 +224,6 @@ def test_repr(self): |
223 | 224 | tzrep = repr(tz) |
224 | 225 | self.assertEqual(tz, eval(tzrep)) |
225 | 226 |
|
226 | | - |
227 | 227 | def test_class_members(self): |
228 | 228 | limit = timedelta(hours=23, minutes=59) |
229 | 229 | self.assertEqual(timezone.utc.utcoffset(None), ZERO) |
@@ -310,6 +310,33 @@ def test_aware_datetime(self): |
310 | 310 | self.assertEqual(tz.dst(t), |
311 | 311 | t.replace(tzinfo=tz).dst()) |
312 | 312 |
|
| 313 | + def test_pickle(self): |
| 314 | + for tz in self.ACDT, self.EST, timezone.min, timezone.max: |
| 315 | + for pickler, unpickler, proto in pickle_choices: |
| 316 | + tz_copy = unpickler.loads(pickler.dumps(tz, proto)) |
| 317 | + self.assertEqual(tz_copy, tz) |
| 318 | + tz = timezone.utc |
| 319 | + for pickler, unpickler, proto in pickle_choices: |
| 320 | + tz_copy = unpickler.loads(pickler.dumps(tz, proto)) |
| 321 | + self.assertIs(tz_copy, tz) |
| 322 | + |
| 323 | + def test_copy(self): |
| 324 | + for tz in self.ACDT, self.EST, timezone.min, timezone.max: |
| 325 | + tz_copy = copy.copy(tz) |
| 326 | + self.assertEqual(tz_copy, tz) |
| 327 | + tz = timezone.utc |
| 328 | + tz_copy = copy.copy(tz) |
| 329 | + self.assertIs(tz_copy, tz) |
| 330 | + |
| 331 | + def test_deepcopy(self): |
| 332 | + for tz in self.ACDT, self.EST, timezone.min, timezone.max: |
| 333 | + tz_copy = copy.deepcopy(tz) |
| 334 | + self.assertEqual(tz_copy, tz) |
| 335 | + tz = timezone.utc |
| 336 | + tz_copy = copy.deepcopy(tz) |
| 337 | + self.assertIs(tz_copy, tz) |
| 338 | + |
| 339 | + |
313 | 340 | ############################################################################# |
314 | 341 | # Base class for testing a particular aspect of timedelta, time, date and |
315 | 342 | # datetime comparisons. |
|
0 commit comments