Esempio n. 1
0
 def assertBuiltinsPickleEqual(self, f1, f2):
   with open(f1, "rb") as pickle1, open(f2, "rb") as pickle2:
     if pickle1.read() == pickle2.read():
       return
   out1 = pytd_utils.LoadPickle(f1, compress=True)
   out2 = pytd_utils.LoadPickle(f2, compress=True)
   raise AssertionError("\n".join(pytd_utils.DiffNamedPickles(out1, out2)))
Esempio n. 2
0
 def testDiffSamePickle(self):
   ast = pytd.TypeDeclUnit("foo", (), (), (), (), ())
   with file_utils.Tempdir() as d:
     filename = os.path.join(d.path, "foo.pickled")
     serialize_ast.StoreAst(ast, filename)
     with open(filename, "rb") as fi:
       data = fi.read()
   named_pickles = [("foo", data)]
   self.assertFalse(pytd_utils.DiffNamedPickles(named_pickles, named_pickles))
Esempio n. 3
0
 def test_diff_pickle_length(self):
   ast = pytd.TypeDeclUnit("foo", (), (), (), (), ())
   with file_utils.Tempdir() as d:
     filename = os.path.join(d.path, "foo.pickled")
     serialize_ast.StoreAst(ast, filename)
     with open(filename, "rb") as fi:
       data = fi.read()
   named_pickles1 = []
   named_pickles2 = [("foo", data)]
   self.assertTrue(pytd_utils.DiffNamedPickles(named_pickles1, named_pickles2))
Esempio n. 4
0
 def testDiffPickleAst(self):
   ast1 = pytd.TypeDeclUnit("foo", (), (), (), (), ())
   ast2 = ast1.Replace(type_params=(pytd.TypeParameter("T", (), None, None),))
   with file_utils.Tempdir() as d:
     data = []
     for ast in (ast1, ast2):
       filename = os.path.join(d.path, "foo.pickled")
       serialize_ast.StoreAst(ast, filename)
       with open(filename, "rb") as fi:
         data.append(fi.read())
   named_pickles1 = [("foo", data[0])]
   named_pickles2 = [("foo", data[1])]
   self.assertTrue(pytd_utils.DiffNamedPickles(named_pickles1, named_pickles2))