def test_watch_not_exists(self): with self.assertRaises(ValueError): with InlineCheckpoint(watch=["a"], produce=["b"]): b = 3 f = Foo() with self.assertRaises(ValueError): with InlineCheckpoint(watch=["f.a"], produce=["b"]): b = 3
def produce_two(): f = Foo() with InlineCheckpoint(watch=[], produce=["f.a", "f.b"]): R() f.a = 1 f.b = 2 return f.a, f.b
def no_watch(): f = Foo() with InlineCheckpoint(watch=[], produce=["f.a"]): R() f.a = 1 return f.a
def default_id(a): f = Foo() f.a = a with InlineCheckpoint(watch=["f.a"], produce=["f.b"]): R() f.b = f.a return f.b
def watch_obj_value(a): f = Foo() f.a = a with InlineCheckpoint(watch=["f.a"], produce=["f.c"]): R() f.c = a return f.c
def test_generator(self): with self.assertRaises(NotInlineCheckableError): def some_generator(): yield 0 f = Foo() with InlineCheckpoint(watch=["some_generator"], produce=["f.a"]): f.a = next(some_generator())
def add_give_c_in_obj(a, b): f = Foo() f.c = "reset" with InlineCheckpoint(watch=["a", "b"], produce=["f.c"]): R() f.c = a + b return f.c
def strange_statement_1(a, b): f = Foo() f.c = "reset" with InlineCheckpoint(watch=('a', "b"), produce=["f.c"]): R() f.c = a + b return f.c
def multi_level(a): f = Foo() f.f = Foo() f.f.f = Foo() f.f.f.a = a with InlineCheckpoint(watch=["f.f.f.a"], produce=["f.f.b"]): R() f.f.b = f.f.f.a return f.f.b
def add_give_c(a, b): c = "reset" with InlineCheckpoint(watch=["a", "b"], produce=["c"]): R() c = a + b return c
def fail_2(): f = Foo() with InlineCheckpoint(watch=["f.a"], produce=["b"]): R() b = f.a return b
def fail_1(): with InlineCheckpoint(watch=["a"], produce=["b"]): R() b = a return b