File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -214,6 +214,10 @@ def __new__(cls, obj):
214214 self .__uuid = obj
215215 return self
216216
217+ def __getnewargs__ (self ):
218+ # Support copy and deepcopy
219+ return (self .__uuid ,)
220+
217221 @property
218222 def uuid (self ):
219223 """UUID instance wrapped by this UUIDLegacy instance.
Original file line number Diff line number Diff line change 1515"""Tests for the Binary wrapper."""
1616
1717import base64
18+ import copy
1819import pickle
1920import sys
2021import unittest
2324 should_test_uuid = True
2425except ImportError :
2526 should_test_uuid = False
27+
2628sys .path [0 :0 ] = ["" ]
2729
2830import bson
@@ -292,6 +294,15 @@ def test_pickle(self):
292294 for proto in xrange (pickle .HIGHEST_PROTOCOL + 1 ):
293295 self .assertEqual (b1 , pickle .loads (pickle .dumps (b1 , proto )))
294296
297+ if should_test_uuid :
298+ uu = uuid .uuid4 ()
299+ uul = UUIDLegacy (uu )
300+
301+ self .assertEqual (uul , copy .copy (uul ))
302+ self .assertEqual (uul , copy .deepcopy (uul ))
303+
304+ for proto in xrange (pickle .HIGHEST_PROTOCOL + 1 ):
305+ self .assertEqual (uul , pickle .loads (pickle .dumps (uul , proto )))
295306
296307if __name__ == "__main__" :
297308 unittest .main ()
You can’t perform that action at this time.
0 commit comments