def test_bound_function_nested_repr(self): f = self._make_pytd_function(params=()) callself1 = self._vm.program.NewVariable( [abstract.AtomicAbstractValue("test1", self._vm)], [], self._vm.root_cfg_node) bound1 = abstract.BoundFunction(callself1, f) callself2 = self._vm.program.NewVariable( [abstract.AtomicAbstractValue("test2", self._vm)], [], self._vm.root_cfg_node) bound2 = abstract.BoundFunction(callself2, bound1) # `bound2` is BoundFunction(test2, BoundFunction(test1, f)) six.assertCountEqual(self, bound2.repr_names(), ["test2.f"])
def test_bound_function_repr_replace_parent(self): f = self._make_pytd_function(params=(), name="foo.f") callself = self._vm.program.NewVariable( [abstract.AtomicAbstractValue("test", self._vm)], [], self._vm.root_cfg_node) bound = abstract.BoundFunction(callself, f) six.assertCountEqual(self, bound.repr_names(), ["test.f"])
def test_bound_function_callself_repr(self): f = self._make_pytd_function(params=()) callself = self._vm.program.NewVariable( [abstract.AtomicAbstractValue("test", self._vm)], [], self._vm.root_cfg_node) bound = abstract.BoundFunction(callself, f) callself_repr = lambda v: v.name + "foo" six.assertCountEqual(self, bound.repr_names(callself_repr), ["testfoo.f"])
def test_bound_function_repr(self): f = self._make_pytd_function(params=()) callself = self._vm.program.NewVariable( [abstract.AtomicAbstractValue(name, self._vm) for name in ("test1", "test2")], [], self._vm.root_cfg_node) bound = abstract.BoundFunction(callself, f) six.assertCountEqual(self, bound.repr_names(), ["test1.f", "test2.f"]) six.assertRegex(self, repr(bound), r"test(1|2)\.f")