Ejemplo n.º 1
0
    def test_dump_and_load(self):
        fndb, ret = trace(main1, [], trace_all=True)
        self.assertEqual(len(fndb), main1_fn_count)

        store = freeze_db(fndb)
        dump = format_db(store)
        dump_direct = format_db(fndb)
        self.assertEqual(dump, dump_direct)

        loaded = load_db(dump)
        self.assertDictEqual(loaded, store)
Ejemplo n.º 2
0
 def test_short_diff(self):
     with tracing(trace_all=True) as fndb1:
         f1('Traced code')
     with tracing(trace_all=True) as fndb2:
         f2('Traced code')
     with tracing(trace_all=True) as fndb3:
         f3('Traced code')
     store1 = freeze_db(fndb1)
     store2 = freeze_db(fndb2)
     store3 = freeze_db(fndb3)
     self.assertEqual(
         short_diff_db(store1, store1), '')
     self.assertEqual(
         short_diff_db(store1, store2),
         '! test_tools:f: x=Traced code -> traced code',
     )
     self.assertEqual(
         short_diff_db(store1, store3),
         '- test_tools:f: x=Traced code -> TRACED CODE\n'
         '+ test_tools:g: x=Traced code -> Traced'
     )