コード例 #1
0
 def test_generate_pyi_with_options(self):
   with self._tmpfile("x: int") as pyi:
     pyi_name, _ = os.path.splitext(os.path.basename(pyi.name))
     with self._tmpfile(
         "{mod} {path}".format(mod=pyi_name, path=pyi.name)) as imports_map:
       src = "import {mod}; y = {mod}.x".format(mod=pyi_name)
       options = config.Options.create(imports_map=imports_map.name)
       _, pyi_string, _ = io.generate_pyi(src, options)
   self.assertEqual(pyi_string, "{mod}: module\ny: int\n".format(mod=pyi_name))
コード例 #2
0
ファイル: io_test.py プロジェクト: umithardal/pytype
 def test_generate_pyi(self):
   with self._tmpfile("x = 42") as f:
     errorlog, pyi_string, pytd_ast = io.generate_pyi(f.name)
   self.assertFalse(errorlog.unique_sorted_errors())
   self.assertEqual(pyi_string, "x: int\n")
   self.assertIsInstance(pytd_ast, pytd.TypeDeclUnit)