50
50
import org .junit .After ;
51
51
import org .junit .Assert ;
52
52
import org .junit .Before ;
53
- import org .junit .Rule ;
54
53
import org .junit .Test ;
55
- import org .junit .rules .ExpectedException ;
56
54
57
55
import com .oracle .graal .python .builtins .modules .PosixModuleBuiltins .FileDescriptorConversionNode ;
58
56
import com .oracle .graal .python .builtins .objects .PNone ;
59
57
import com .oracle .graal .python .builtins .objects .frame .PFrame ;
60
58
import com .oracle .graal .python .builtins .objects .function .PArguments ;
61
59
import com .oracle .graal .python .runtime .ExecutionContext ;
62
60
import com .oracle .graal .python .runtime .PythonContext ;
63
- import com .oracle .graal .python .runtime .exception .PException ;
64
61
import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
65
62
import com .oracle .graal .python .test .PythonTests ;
66
63
import com .oracle .truffle .api .RootCallTarget ;
67
64
import com .oracle .truffle .api .Truffle ;
68
65
import com .oracle .truffle .api .frame .VirtualFrame ;
69
66
import com .oracle .truffle .api .nodes .RootNode ;
70
67
71
- public class FileDescriptorConversionNodeTests {
72
- @ Rule public ExpectedException expectedException = ExpectedException .none ();
68
+ public class FileDescriptorConversionNodeTests extends ConversionNodeTests {
73
69
74
70
@ Before
75
71
public void setUp () {
@@ -83,16 +79,14 @@ public void tearDown() {
83
79
84
80
@ Test
85
81
public void none () {
86
- expectedException .expect (PException .class );
87
- expectedException .expectMessage ("TypeError: argument must be an int, or have a fileno() method." );
82
+ expectPythonMessage ("TypeError: argument must be an int, or have a fileno() method." );
88
83
call (PNone .NONE );
89
84
Assert .assertEquals (AT_FDCWD .value , call (PNone .NO_VALUE ));
90
85
}
91
86
92
87
@ Test
93
88
public void noValue () {
94
- expectedException .expect (PException .class );
95
- expectedException .expectMessage ("TypeError: argument must be an int, or have a fileno() method." );
89
+ expectPythonMessage ("TypeError: argument must be an int, or have a fileno() method." );
96
90
call (PNone .NO_VALUE );
97
91
}
98
92
@@ -114,15 +108,13 @@ public void longFitsInt() {
114
108
115
109
@ Test
116
110
public void longTooBig () {
117
- expectedException .expect (PException .class );
118
- expectedException .expectMessage ("OverflowError: Python int too large to convert to int" );
111
+ expectPythonMessage ("OverflowError: Python int too large to convert to int" );
119
112
call (1L << 40 );
120
113
}
121
114
122
115
@ Test
123
116
public void longTooSmall () {
124
- expectedException .expect (PException .class );
125
- expectedException .expectMessage ("OverflowError: Python int too large to convert to int" );
117
+ expectPythonMessage ("OverflowError: Python int too large to convert to int" );
126
118
call (-1L << 40 );
127
119
}
128
120
@@ -133,22 +125,19 @@ public void pintFitsInt() {
133
125
134
126
@ Test
135
127
public void pintTooBig () {
136
- expectedException .expect (PException .class );
137
- expectedException .expectMessage ("OverflowError: Python int too large to convert to int" );
128
+ expectPythonMessage ("OverflowError: Python int too large to convert to int" );
138
129
call (factory ().createInt (BigInteger .ONE .shiftLeft (100 )));
139
130
}
140
131
141
132
@ Test
142
133
public void pintTooSmall () {
143
- expectedException .expect (PException .class );
144
- expectedException .expectMessage ("OverflowError: Python int too large to convert to int" );
134
+ expectPythonMessage ("OverflowError: Python int too large to convert to int" );
145
135
call (factory ().createInt (BigInteger .ONE .shiftLeft (100 ).negate ()));
146
136
}
147
137
148
138
@ Test
149
139
public void indexNotUsed () {
150
- expectedException .expect (PException .class );
151
- expectedException .expectMessage ("TypeError: argument must be an int, or have a fileno() method." );
140
+ expectPythonMessage ("TypeError: argument must be an int, or have a fileno() method." );
152
141
call (evalValue ("class C:\n def __index__(self):\n return 42\n C()" ));
153
142
}
154
143
@@ -159,22 +148,19 @@ public void filenoOk() {
159
148
160
149
@ Test
161
150
public void filenoWrongType () {
162
- expectedException .expect (PException .class );
163
- expectedException .expectMessage ("TypeError: fileno() returned a non-integer" );
151
+ expectPythonMessage ("TypeError: fileno() returned a non-integer" );
164
152
call (evalValue ("class C:\n def fileno(self):\n return 3.14\n C()" ));
165
153
}
166
154
167
155
@ Test
168
156
public void filenoTooBig () {
169
- expectedException .expect (PException .class );
170
- expectedException .expectMessage ("OverflowError: Python int too large to convert to int" );
157
+ expectPythonMessage ("OverflowError: Python int too large to convert to int" );
171
158
call (evalValue ("class C:\n def fileno(self):\n return 1 << 40\n C()" ));
172
159
}
173
160
174
161
@ Test
175
162
public void unsupportedType1 () {
176
- expectedException .expect (PException .class );
177
- expectedException .expectMessage ("TypeError: argument must be an int, or have a fileno() method." );
163
+ expectPythonMessage ("TypeError: argument must be an int, or have a fileno() method." );
178
164
call (3.14 );
179
165
}
180
166
0 commit comments