#1053 Fixed unpickled datetimes with `tzutc` has a new (different) instance of `tzutc`. Same applies for `tzoffset`.

Open Jordi Masip masipcat
Showing 2 of 4 files from the diff.

@@ -120,7 +120,8 @@
Loading
120 120
    def __repr__(self):
121 121
        return "%s()" % self.__class__.__name__
122 122
123 -
    __reduce__ = object.__reduce__
123 +
    def __reduce__(self):
124 +
        return (self.__class__, tuple())
124 125
125 126
126 127
#: Convenience constant providing a :class:`tzutc()` instance
@@ -195,7 +196,8 @@
Loading
195 196
                               repr(self._name),
196 197
                               int(self._offset.total_seconds()))
197 198
198 -
    __reduce__ = object.__reduce__
199 +
    def __reduce__(self):
200 +
        return (self.__class__, (self._name, self._offset))
199 201
200 202
201 203
class tzlocal(_tzinfo):

@@ -33,15 +33,17 @@
Loading
33 33
                        dump_kwargs=None, load_kwargs=None):
34 34
        """
35 35
        Assert that an object can be pickled and unpickled. This assertion
36 -
        assumes that the desired behavior is that the unpickled object compares
37 -
        equal to the original object, but is not the same object.
36 +
        assumes that the desired behavior is that the unpickled object is the same
37 +
        as the original, when singleton=True.
38 38
        """
39 39
        get_nobj = self._get_nobj_file if asfile else self._get_nobj_bytes
40 40
        dump_kwargs = dump_kwargs or {}
41 41
        load_kwargs = load_kwargs or {}
42 42
43 43
        nobj = get_nobj(obj, dump_kwargs, load_kwargs)
44 -
        if not singleton:
44 +
        if singleton:
45 +
            self.assertIs(obj, nobj)
46 +
        else:
45 47
            self.assertIsNot(obj, nobj)
46 48
        self.assertEqual(obj, nobj)
47 49

Learn more Showing 32 files with coverage changes found.

Changes in dateutil/test/_common.py
+100
+10
Loading file...
Changes in dateutil/tz/tz.py
+728
+70
Loading file...
Changes in dateutil/zoneinfo/rebuild.py
+11
+28
Loading file...
Changes in dateutil/test/test_easter.py
+19
Loading file...
Changes in dateutil/test/test_imports.py
+104
Loading file...
Changes in dateutil/test/test_isoparser.py
+223
Loading file...
Changes in dateutil/zoneinfo/__init__.py
+45
+9
Loading file...
Changes in dateutil/test/conftest.py
+14
+6
Loading file...
Changes in dateutil/tz/win.py
+138
+15
Loading file...
Changes in dateutil/utils.py
+14
Loading file...
Changes in dateutil/tz/_factories.py
+49
Loading file...
Changes in dateutil/rrule.py
+927
+53
Loading file...
Changes in dateutil/parser/_parser.py
+782
+33
Loading file...
Changes in dateutil/test/test_internals.py
+57
Loading file...
Changes in dateutil/test/test_import_star.py
+22
Loading file...
Changes in dateutil/parser/isoparser.py
+180
Loading file...
Changes in dateutil/_common.py
+24
+1
Loading file...
Changes in dateutil/relativedelta.py
+241
Loading file...
Changes in dateutil/parser/__init__.py
+33
Loading file...
Changes in dateutil/__init__.py
+3
+2
Loading file...
Changes in dateutil/test/test_tz.py
+1406
+19
Loading file...
Changes in dateutil/easter.py
+27
Loading file...
Changes in dateutil/test/property/test_tz_prop.py
+22
Loading file...
Changes in dateutil/test/test_relativedelta.py
+329
+2
Loading file...
Changes in dateutil/tz/_common.py
+147
+14
Loading file...
Changes in dateutil/test/test_utils.py
+34
Loading file...
Changes in dateutil/test/test_parser.py
+425
+51
Loading file...
Changes in dateutil/test/property/test_isoparse_prop.py
+16
Loading file...
Changes in dateutil/test/test_rrule.py
+1338
+5
Loading file...
Changes in dateutil/tzwin.py
+1
Loading file...
Changes in dateutil/tz/__init__.py
+4
Loading file...
Changes in dateutil/test/property/test_parser_prop.py
+15
Loading file...
Files Coverage
Project Totals (32 files) 95.93%
Loading