def test_basic(self): tracer = VizTracer() tracer.start() a = VizObject(tracer, "my variable") a.hello = 1 a.hello = 2 tracer.stop() entries = tracer.parse() self.assertEqual(entries, 3)
def test_buffer_wrap(self): tracer = VizTracer(tracer_entries=10) tracer.start() a = VizObject(tracer, "my variable") for i in range(15): a.hello = i tracer.stop() entries = tracer.parse() tracer.save() self.assertEqual(entries, 10)
def test_notracer(self): a = VizObject(None, "my variable") a.hello = 1 a.hello = 2 a = Hello(None) a.config("include_attributes", ["a", "b"]) a.change_val() a.change_val2() b = Hello(None) b.config("include_attributes", ["a", "b"]) b.change_val() b.change_val2()
def test_config(self): tracer = VizTracer() tracer.start() a = VizObject(tracer, "my variable") a.config("trigger_on_change", False) a.hello = 1 a.b = 2 a.c = 3 a.lol = 4 a.log() tracer.stop() del a entries = tracer.parse() self.assertEqual(entries, 2)
def test_trigger_on_change(self): tracer = VizTracer() tracer.stop() tracer.cleanup() tracer.start() a = VizObject(tracer, "my variable", trigger_on_change=False) a.hello = 1 a.b = 2 a.c = 3 a.lol = 4 a.log() tracer.stop() entries = tracer.parse() self.assertEqual(entries, 2)
def test_exclude(self): tracer = VizTracer() tracer.start() a = VizObject(tracer, "my variable", exclude_attributes=["b", "c"]) a.hello = 1 a.b = 2 a.c = 3 a.lol = 4 tracer.stop() entries = tracer.parse() self.assertEqual(entries, 3)
def test_config(self): tracer = VizTracer() tracer.start() a = VizObject(tracer, "my variable") a.config("trigger_on_change", False) a.hello = 1 a.b = 2 a.c = 3 a.lol = 4 a.log() tracer.stop() entries = tracer.parse() self.assertEqual(entries, 2) with self.assertRaises(ValueError): a.config("invalid", "value")
def g(a, b): a += h(a) b += 3 # raise Exception("lol") def f(a, b): # wthell.wth() a = a + 2 ob.s = str(b) g(a + 1, b * 2) # wthell.wth() h(36) def t(a): f(a + 1, a + 2) a += 3 f(a + 5, 2) tracer = VizTracer() counter = VizCounter(tracer, "a") ob = VizObject(tracer, "b") tracer.start() t(3) tracer.stop() tracer.save("vdb_basic.json")