Beispiel #1
0
 def dump_load(self, **data):
     s = dumps(data)
     restored = loads(s)
     eq_(len(data), len(restored))
     eq_(data.keys(), restored.keys())
     for key in data.keys():
         eq_(data[key], restored[key])
Beispiel #2
0
 def load(self, data):
     # FIXME: The type is deprecated. remove this
     if not hasattr(data, 'items'):
         data = serializer.loads(data)
     if "type" in data:
         data["task_type"] = data["type"]
         del data["type"]
     super(ProblemData, self).load(data)
Beispiel #3
0
 def loads(self, data):
     try:
         if not hasattr(data, 'items'):
             data = serializer.loads(data)
         for field_name, value in data.items():
             field = self._meta.get_field(field_name)
             setattr(self, field.attname, field.loads(value))
     except (ValueError, KeyError) as e:
         raise self.InvalidObject(e)
Beispiel #4
0
 def loads(self, data):
     try:
         if not hasattr(data, 'items'):
             data = serializer.loads(data)
         for field_name, value in data.items():
             field = self._meta.get_field(field_name)
             setattr(self, field.attname, field.loads(value))
     except (ValueError, KeyError) as e:
         raise self.InvalidObject(e)
Beispiel #5
0
 def test_blankline_with_space(self):
     data = loads(' ')
     eq_(len(data), 0)
Beispiel #6
0
 def test_blankline(self):
     data = loads('')
     eq_(len(data), 0)
Beispiel #7
0
 def test_multiline_comment(self):
     data = loads('# foo\n    bar\n    baz')
     eq_(len(data), 0)
Beispiel #8
0
 def test_comment(self):
     data = loads('# foo')
     eq_(len(data), 0)
Beispiel #9
0
 def test_multiline(self):
     data = loads('multiline: foo\n    bar\n    baz')
     eq_(len(data), 1)
     eq_(data['multiline'], 'foo\nbar\nbaz')
Beispiel #10
0
 def test_oneline(self):
     data = loads('oneline: foo')
     eq_(len(data), 1)
     eq_(data['oneline'], 'foo')
Beispiel #11
0
 def test_none(self):
     data = loads('none: ')
     eq_(len(data), 1)
     eq_(data['none'], None)