|
3 | 3 | See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases |
4 | 4 | """ |
5 | 5 |
|
| 6 | +import copy |
6 | 7 | import decimal |
7 | 8 | import sys |
8 | 9 | import pickle |
@@ -235,7 +236,6 @@ def test_repr(self): |
235 | 236 | tzrep = repr(tz) |
236 | 237 | self.assertEqual(tz, eval(tzrep)) |
237 | 238 |
|
238 | | - |
239 | 239 | def test_class_members(self): |
240 | 240 | limit = timedelta(hours=23, minutes=59) |
241 | 241 | self.assertEqual(timezone.utc.utcoffset(None), ZERO) |
@@ -322,6 +322,33 @@ def test_aware_datetime(self): |
322 | 322 | self.assertEqual(tz.dst(t), |
323 | 323 | t.replace(tzinfo=tz).dst()) |
324 | 324 |
|
| 325 | + def test_pickle(self): |
| 326 | + for tz in self.ACDT, self.EST, timezone.min, timezone.max: |
| 327 | + for pickler, unpickler, proto in pickle_choices: |
| 328 | + tz_copy = unpickler.loads(pickler.dumps(tz, proto)) |
| 329 | + self.assertEqual(tz_copy, tz) |
| 330 | + tz = timezone.utc |
| 331 | + for pickler, unpickler, proto in pickle_choices: |
| 332 | + tz_copy = unpickler.loads(pickler.dumps(tz, proto)) |
| 333 | + self.assertIs(tz_copy, tz) |
| 334 | + |
| 335 | + def test_copy(self): |
| 336 | + for tz in self.ACDT, self.EST, timezone.min, timezone.max: |
| 337 | + tz_copy = copy.copy(tz) |
| 338 | + self.assertEqual(tz_copy, tz) |
| 339 | + tz = timezone.utc |
| 340 | + tz_copy = copy.copy(tz) |
| 341 | + self.assertIs(tz_copy, tz) |
| 342 | + |
| 343 | + def test_deepcopy(self): |
| 344 | + for tz in self.ACDT, self.EST, timezone.min, timezone.max: |
| 345 | + tz_copy = copy.deepcopy(tz) |
| 346 | + self.assertEqual(tz_copy, tz) |
| 347 | + tz = timezone.utc |
| 348 | + tz_copy = copy.deepcopy(tz) |
| 349 | + self.assertIs(tz_copy, tz) |
| 350 | + |
| 351 | + |
325 | 352 | ############################################################################# |
326 | 353 | # Base class for testing a particular aspect of timedelta, time, date and |
327 | 354 | # datetime comparisons. |
|
0 commit comments