Esempio n. 1
0
 def test_loader_uses_decimal_to_parse_numbers(self):
     text = """
     {
         "number": 1.5
     }
     """
     doc = JSON.loads(text)
     number = doc["number"]
     self.assertEqual(number, Decimal("1.5"))
     self.assertTrue(isinstance(number, Decimal))
Esempio n. 2
0
 def test_loader_uses_decimal_to_parse_numbers(self):
     text = """
     {
         "number": 1.5
     }
     """
     doc = JSON.loads(text)
     number = doc["number"]
     self.assertEqual(number, Decimal("1.5"))
     self.assertTrue(isinstance(number, Decimal))
Esempio n. 3
0
 def test_dumper_can_dump_decimals(self):
     doc = {
         "format": "Dashboard Bundle Format 1.0",
         "test_runs": [
             {
                 "test_id": "NOT RELEVANT",
                 "analyzer_assigned_date": "2010-11-14T01:03:06Z",
                 "analyzer_assigned_uuid": "NOT RELEVANT",
                 "time_check_performed": False,
                 "test_results": [
                     {
                         "test_case_id": "NOT RELEVANT",
                         "result": "unknown",
                         "measurement": Decimal("1.5")}]}]}
     text = JSON.dumps(doc)
     self.assertIn("1.5", text)
Esempio n. 4
0
 def test_dumper_can_dump_decimals(self):
     doc = {
         "format":
         "Dashboard Bundle Format 1.0",
         "test_runs": [{
             "test_id":
             "NOT RELEVANT",
             "analyzer_assigned_date":
             "2010-11-14T01:03:06Z",
             "analyzer_assigned_uuid":
             "NOT RELEVANT",
             "time_check_performed":
             False,
             "test_results": [{
                 "test_case_id": "NOT RELEVANT",
                 "result": "unknown",
                 "measurement": Decimal("1.5")
             }]
         }]
     }
     text = JSON.dumps(doc)
     self.assertIn("1.5", text)
Esempio n. 5
0
 def test_dump_produces_readable_output(self):
     stream = StringIO()
     JSON.dump(stream, self.doc, human_readable=True)
     observed_text = stream.getvalue()
     self.assertEqual(observed_text, self.expected_readable_text)
Esempio n. 6
0
 def test_dumps_produces_compact_sorted_ouptut(self):
     observed_text = JSON.dumps(
         self.doc, human_readable=False, sort_keys=True)
     self.assertEqual(observed_text, self.expected_compact_sorted_text)
Esempio n. 7
0
 def test_dumps_produces_readable_ouptut(self):
     observed_text = JSON.dumps(self.doc, human_readable=True)
     self.assertEqual(observed_text, self.expected_readable_text)
Esempio n. 8
0
 def test_dumps_produces_compact_sorted_ouptut(self):
     observed_text = JSON.dumps(self.doc,
                                human_readable=False,
                                sort_keys=True)
     self.assertEqual(observed_text, self.expected_compact_sorted_text)
Esempio n. 9
0
 def test_load__with_enabled_retain_order__dict_class(self):
     doc = JSON.load(self.stream, retain_order=True)
     observed_impl = type(doc)
     # Note:    VVV
     self.assertNotEqual(observed_impl, dict)
Esempio n. 10
0
 def test_load__return_value(self):
     doc = JSON.load(self.stream)
     self.assertEqual(doc, self.expected_doc)
Esempio n. 11
0
 def test_load__return_value(self):
     doc = JSON.load(self.stream)
     self.assertEqual(doc, self.expected_doc)
Esempio n. 12
0
 def test_loads__return_value(self):
     doc = JSON.loads(self.text)
     self.assertEqual(doc, self.expected_doc)
Esempio n. 13
0
 def test_dump_produces_compact_sorted_output(self):
     stream = StringIO()
     JSON.dump(stream, self.doc, human_readable=False, sort_keys=True)
     observed_text = stream.getvalue()
     self.assertEqual(observed_text, self.expected_compact_sorted_text)
Esempio n. 14
0
 def test_dump_produces_readable_output(self):
     stream = StringIO()
     JSON.dump(stream, self.doc, human_readable=True)
     observed_text = stream.getvalue()
     self.assertEqual(observed_text, self.expected_readable_text)
Esempio n. 15
0
 def test_dump_produces_compact_sorted_output(self):
     stream = StringIO()
     JSON.dump(stream, self.doc, human_readable=False, sort_keys=True)
     observed_text = stream.getvalue()
     self.assertEqual(observed_text, self.expected_compact_sorted_text)
Esempio n. 16
0
 def test_load__with_enabled_retain_order__key_order(self):
     doc = JSON.load(self.stream, retain_order=True)
     observed_keys = list(doc.keys())
     self.assertEqual(observed_keys, self.expected_keys)
Esempio n. 17
0
 def test_load__with_enabled_retain_order__dict_class(self):
     doc = JSON.load(self.stream, retain_order=True)
     observed_impl = type(doc)
     # Note:    VVV
     self.assertNotEqual(observed_impl, dict)
Esempio n. 18
0
 def test_loads__return_value(self):
     doc = JSON.loads(self.text)
     self.assertEqual(doc, self.expected_doc)
Esempio n. 19
0
 def test_load__with_disabled_retain_order__dict_class(self):
     doc = JSON.load(self.stream, retain_order=False)
     expected_impl = dict
     observed_impl = type(doc)
     self.assertEqual(observed_impl, expected_impl)
Esempio n. 20
0
 def test_load__with_enabled_retain_order__key_order(self):
     doc = JSON.load(self.stream, retain_order=True)
     observed_keys = list(doc.keys())
     self.assertEqual(observed_keys, self.expected_keys)
Esempio n. 21
0
 def test_loads__with_enabled_retain_order__key_order(self):
     doc = JSON.loads(self.text, retain_order=True)
     observed_keys = doc.keys()
     self.assertEqual(observed_keys, self.expected_keys)
Esempio n. 22
0
 def test_loads__with_disabled_retain_order__dict_class(self):
     doc = JSON.loads(self.text, retain_order=False)
     expected_impl = dict
     observed_impl = type(doc)
     self.assertEqual(observed_impl, expected_impl)
Esempio n. 23
0
 def test_dumps_produces_readable_ouptut(self):
     observed_text = JSON.dumps(self.doc, human_readable=True)
     self.assertEqual(observed_text, self.expected_readable_text)