3
3
import __future__
4
4
import ast
5
5
import unittest
6
- from test import support
7
6
from test .support import import_helper
7
+ from test .support .script_helper import spawn_python , kill_python
8
8
from textwrap import dedent
9
9
import os
10
10
import re
@@ -25,73 +25,87 @@ def check_syntax_error(self, err, basename, lineno, offset=1):
25
25
self .assertEqual (err .offset , offset )
26
26
27
27
def test_future1 (self ):
28
- with import_helper .CleanImport ('future_test1' ):
29
- from test import future_test1
28
+ with import_helper .CleanImport ('test.test_future_stmt. future_test1' ):
29
+ from test . test_future_stmt import future_test1
30
30
self .assertEqual (future_test1 .result , 6 )
31
31
32
32
def test_future2 (self ):
33
- with import_helper .CleanImport ('future_test2' ):
34
- from test import future_test2
33
+ with import_helper .CleanImport ('test.test_future_stmt. future_test2' ):
34
+ from test . test_future_stmt import future_test2
35
35
self .assertEqual (future_test2 .result , 6 )
36
36
37
- def test_future3 (self ):
38
- with import_helper .CleanImport ('test_future3' ):
39
- from test import test_future3
37
+ def test_future_single_import (self ):
38
+ with import_helper .CleanImport (
39
+ 'test.test_future_stmt.test_future_single_import' ,
40
+ ):
41
+ from test .test_future_stmt import test_future_single_import
42
+
43
+ def test_future_multiple_imports (self ):
44
+ with import_helper .CleanImport (
45
+ 'test.test_future_stmt.test_future_multiple_imports' ,
46
+ ):
47
+ from test .test_future_stmt import test_future_multiple_imports
48
+
49
+ def test_future_multiple_features (self ):
50
+ with import_helper .CleanImport (
51
+ "test.test_future_stmt.test_future_multiple_features" ,
52
+ ):
53
+ from test .test_future_stmt import test_future_multiple_features
40
54
41
55
# TODO: RUSTPYTHON
42
56
@unittest .expectedFailure
43
57
def test_badfuture3 (self ):
44
58
with self .assertRaises (SyntaxError ) as cm :
45
- from test import badsyntax_future3
59
+ from test . test_future_stmt import badsyntax_future3
46
60
self .check_syntax_error (cm .exception , "badsyntax_future3" , 3 )
47
61
48
62
# TODO: RUSTPYTHON
49
63
@unittest .expectedFailure
50
64
def test_badfuture4 (self ):
51
65
with self .assertRaises (SyntaxError ) as cm :
52
- from test import badsyntax_future4
66
+ from test . test_future_stmt import badsyntax_future4
53
67
self .check_syntax_error (cm .exception , "badsyntax_future4" , 3 )
54
68
55
69
# TODO: RUSTPYTHON
56
70
@unittest .expectedFailure
57
71
def test_badfuture5 (self ):
58
72
with self .assertRaises (SyntaxError ) as cm :
59
- from test import badsyntax_future5
73
+ from test . test_future_stmt import badsyntax_future5
60
74
self .check_syntax_error (cm .exception , "badsyntax_future5" , 4 )
61
75
62
76
# TODO: RUSTPYTHON
63
77
@unittest .expectedFailure
64
78
def test_badfuture6 (self ):
65
79
with self .assertRaises (SyntaxError ) as cm :
66
- from test import badsyntax_future6
80
+ from test . test_future_stmt import badsyntax_future6
67
81
self .check_syntax_error (cm .exception , "badsyntax_future6" , 3 )
68
82
69
83
# TODO: RUSTPYTHON
70
84
@unittest .expectedFailure
71
85
def test_badfuture7 (self ):
72
86
with self .assertRaises (SyntaxError ) as cm :
73
- from test import badsyntax_future7
74
- self .check_syntax_error (cm .exception , "badsyntax_future7" , 3 , 53 )
87
+ from test . test_future_stmt import badsyntax_future7
88
+ self .check_syntax_error (cm .exception , "badsyntax_future7" , 3 , 54 )
75
89
76
90
# TODO: RUSTPYTHON
77
91
@unittest .expectedFailure
78
92
def test_badfuture8 (self ):
79
93
with self .assertRaises (SyntaxError ) as cm :
80
- from test import badsyntax_future8
94
+ from test . test_future_stmt import badsyntax_future8
81
95
self .check_syntax_error (cm .exception , "badsyntax_future8" , 3 )
82
96
83
97
# TODO: RUSTPYTHON
84
98
@unittest .expectedFailure
85
99
def test_badfuture9 (self ):
86
100
with self .assertRaises (SyntaxError ) as cm :
87
- from test import badsyntax_future9
101
+ from test . test_future_stmt import badsyntax_future9
88
102
self .check_syntax_error (cm .exception , "badsyntax_future9" , 3 )
89
103
90
104
# TODO: RUSTPYTHON
91
105
@unittest .expectedFailure
92
106
def test_badfuture10 (self ):
93
107
with self .assertRaises (SyntaxError ) as cm :
94
- from test import badsyntax_future10
108
+ from test . test_future_stmt import badsyntax_future10
95
109
self .check_syntax_error (cm .exception , "badsyntax_future10" , 3 )
96
110
97
111
def test_ensure_flags_dont_clash (self ):
@@ -129,15 +143,20 @@ def test_parserhack(self):
129
143
else :
130
144
self .fail ("syntax error didn't occur" )
131
145
132
- def test_multiple_features (self ):
133
- with import_helper .CleanImport ("test.test_future5" ):
134
- from test import test_future5
135
-
136
146
def test_unicode_literals_exec (self ):
137
147
scope = {}
138
148
exec ("from __future__ import unicode_literals; x = ''" , {}, scope )
139
149
self .assertIsInstance (scope ["x" ], str )
140
150
151
+ # TODO: RUSTPYTHON
152
+ @unittest .expectedFailure
153
+ def test_syntactical_future_repl (self ):
154
+ p = spawn_python ('-i' )
155
+ p .stdin .write (b"from __future__ import barry_as_FLUFL\n " )
156
+ p .stdin .write (b"2 <> 3\n " )
157
+ out = kill_python (p )
158
+ self .assertNotIn (b'SyntaxError: invalid syntax' , out )
159
+
141
160
class AnnotationsFutureTestCase (unittest .TestCase ):
142
161
template = dedent (
143
162
"""
0 commit comments