Esempio n. 1
0
 def format_output_data(self, data):
     # Modify data to make it more readable
     if self.resource in data:
         for k, v in data[self.resource].iteritems():
             if isinstance(v, list):
                 value = '\n'.join(
                     utils.dumps(i, indent=self.json_indent
                                 ) if isinstance(i, dict) else str(i)
                     for i in v)
                 data[self.resource][k] = value
             elif isinstance(v, dict):
                 value = utils.dumps(v, indent=self.json_indent)
                 data[self.resource][k] = value
             elif v is None:
                 data[self.resource][k] = ''
Esempio n. 2
0
 def test_dumps_dict_with_spaces(self):
     x = datetime.datetime(1920, 2, 3, 4, 5, 6, 7)
     res = utils.dumps({1: 'a ', 2: x})
     expected = '{"1": "a ", "2": "1920-02-03 04:05:06.000007"}'
     self.assertEqual(expected, res)
 def test_dumps_dict_with_spaces(self):
     x = datetime.datetime(1920, 2, 3, 4, 5, 6, 7)
     res = utils.dumps({1: 'a ', 2: x})
     expected = '{"1": "a ", "2": "1920-02-03 04:05:06.000007"}'
     self.assertEqual(expected, res)
Esempio n. 4
0
 def test_dumps(self):
     self.assertEqual(utils.dumps({'a': 'b'}), '{"a": "b"}')
 def test_dumps(self):
     self.assertEqual(utils.dumps({'a': 'b'}), '{"a": "b"}')