@@ -2850,21 +2850,6 @@ def test_print_op_module(self):
28502850
28512851
28522852class TestScript(JitTestCase):
2853-     class capture_stdout(list):
2854-         """
2855-         Replace sys.stdout with a temporary StringIO
2856-         """
2857-         def __enter__(self):
2858-             self.sys_stdout = sys.stdout
2859-             self.stringio = StringIO()
2860-             sys.stdout = self.stringio
2861-             return self
2862- 
2863-         def __exit__(self, *args):
2864-             self.append(str(self.stringio.getvalue()))
2865-             del self.stringio
2866-             sys.stdout = self.sys_stdout
2867- 
28682853    def test_sequence_parsing(self):
28692854        tests = [
28702855            ("return [x, x,]", True),
@@ -3194,35 +3179,6 @@ def annotate_none_no_optional():
31943179        self.checkScript(annotate_none, ())
31953180        self.checkScript(annotate_none_no_optional, ())
31963181
3197-     @unittest.skipIf(True, "Python 3 required")
3198-     def test_type_annotate_py3(self):
3199-         code = dedent("""
3200-         import torch
3201-         def fn():
3202-             a : List[int] = []
3203-             b : torch.Tensor = torch.ones(2, 2)
3204-             for _ in range(10):
3205-                 a.append(4)
3206-             return a, b
3207-         """)
3208- 
3209-         with tempfile.TemporaryDirectory() as tmp_dir:
3210-             script_path = os.path.join(tmp_dir, 'script.py')
3211-             with open(script_path, 'w') as f:
3212-                 f.write(code)
3213-             fn = get_fn('test_type_annotate_py3', script_path)
3214- 
3215-             self.checkScript(fn, ())
3216- 
3217-         code = dedent("""
3218-         def wrong_type():
3219-             wrong : List[int] = [0.5]
3220-             return wrong
3221-         """)
3222- 
3223-         with self.assertRaisesRegex(RuntimeError, "Lists must contain only a single type"):
3224-             cu = torch.jit.CompilationUnit(code)
3225- 
32263182    def test_robust_op_resolution(self):
32273183        neg = torch.add  # misleading name to make sure we resolve by function
32283184
@@ -7862,7 +7818,7 @@ def foo(i):
78627818        v = torch.rand(10, 3)
78637819        self.checkScript(foo, (v,))
78647820
7865-         with self.assertRaisesRegex(RuntimeError, r"variable  'a' previously has type Tuple"):
7821+         with self.assertRaisesRegex(RuntimeError, r"Variable  'a' previously has type Tuple"):
78667822            @torch.jit.script
78677823            def mixtypes(x):
78687824                a = (x, x)
@@ -7890,7 +7846,7 @@ def diff_type_used():
78907846                    c0 = 1.0
78917847                return c0
78927848
7893-         with self.assertRaisesRegex(RuntimeError, "variable  'c0' previously has type float"):
7849+         with self.assertRaisesRegex(RuntimeError, "Variable  'c0' previously has type float"):
78947850            @torch.jit.script
78957851            def diff_existing_type(x):
78967852                c0 = 1.0
0 commit comments