File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,9 @@ def __str__(self):
2222
2323 def __unicode__ (self ):
2424 return '<%s %s>' % (self .method .title (), self .original_url or "" )
25+
26+ def __getitem__ (self , key ):
27+ if (key in self .data ) and (self .data [key ] == None ):
28+ return ''
29+ else :
30+ return self .data [key ]
Original file line number Diff line number Diff line change @@ -61,7 +61,13 @@ def test_model(self):
6161 self .assertEqual (obj ['new_key' ], 'dict value' )
6262
6363 def test_model_data_can_serialize (self ):
64- obj = Url ({'a' : {'key' : 'value' }})
64+ obj = Url ({'hash' : {'key' : 'value' },
65+ 'none' : None ,
66+ 'empty' : '' ,
67+ 'float' : 1.234 ,
68+ 'int' : 1 ,
69+ 'string' : 'string' ,
70+ 'array' : [0 , - 1 ]})
6571 unserialzed = json .loads (json .dumps (obj .data ))
6672 self .assertDictEqual (obj .data , unserialzed )
6773
You can’t perform that action at this time.
0 commit comments