Exemple #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])
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #5
0
 def test_blankline_with_space(self):
     data = loads(' ')
     eq_(len(data), 0)
Exemple #6
0
 def test_blankline(self):
     data = loads('')
     eq_(len(data), 0)
Exemple #7
0
 def test_multiline_comment(self):
     data = loads('# foo\n    bar\n    baz')
     eq_(len(data), 0)
Exemple #8
0
 def test_comment(self):
     data = loads('# foo')
     eq_(len(data), 0)
Exemple #9
0
 def test_multiline(self):
     data = loads('multiline: foo\n    bar\n    baz')
     eq_(len(data), 1)
     eq_(data['multiline'], 'foo\nbar\nbaz')
Exemple #10
0
 def test_oneline(self):
     data = loads('oneline: foo')
     eq_(len(data), 1)
     eq_(data['oneline'], 'foo')
Exemple #11
0
 def test_none(self):
     data = loads('none: ')
     eq_(len(data), 1)
     eq_(data['none'], None)