예제 #1
0
 def testCollectDependenciesOnFunctionType(self):
   other = self.Parse("""
     def f(): ...
   """)
   ast = pytd.FunctionType("foo.bar", other.Lookup("f"))
   deps = visitors.CollectDependencies()
   ast.Visit(deps)
   six.assertCountEqual(self, {"foo"}, deps.dependencies)
예제 #2
0
 def testFunctionPickle(self):
     test_obj = "x1"
     f = pytd.FunctionType("test_name", test_obj)
     pickled_f = cPickle.dumps(f, pickle.HIGHEST_PROTOCOL)
     unpickled_f = cPickle.loads(pickled_f)
     # Objects can not be directly compared, as they use the NamedTuple equals.
     # Which does not know about .function.
     self.assertEqual(f.name, unpickled_f.name)
     self.assertEqual(f.function, unpickled_f.function)
예제 #3
0
 def testFillInFunctionTypePointers(self):
   src = textwrap.dedent("def f(): ...")
   tree = self.Parse(src)
   ty = pytd.FunctionType("f", None)
   ty.Visit(visitors.FillInLocalPointers({"": tree}))
   self.assertEqual(ty.function, tree.Lookup("f"))