Merge pull request #3701 from Cheglader/master

Fix #3628 by implementing __getnewargs__()
This commit is contained in:
Xavier Ordoquy 2015-12-07 10:45:06 +01:00
commit 6bbb2890cb
2 changed files with 14 additions and 0 deletions

View File

@ -32,6 +32,9 @@ class Hyperlink(six.text_type):
ret.name = name ret.name = name
return ret return ret
def __getnewargs__(self):
return(str(self), self.name,)
is_hyperlink = True is_hyperlink = True

View File

@ -206,3 +206,14 @@ class TestManyRelatedField(APISimpleTestCase):
mvd = MultiValueDict({'baz': ['bar1', 'bar2']}) mvd = MultiValueDict({'baz': ['bar1', 'bar2']})
assert empty == self.field.get_value(mvd) assert empty == self.field.get_value(mvd)
class TestHyperlink:
def setup(self):
self.default_hyperlink = serializers.Hyperlink('http://example.com', 'test')
def test_can_be_pickled(self):
import pickle
upkled = pickle.loads(pickle.dumps(self.default_hyperlink))
assert upkled == self.default_hyperlink
assert upkled.name == self.default_hyperlink.name