5050import org .junit .After ;
5151import org .junit .Assert ;
5252import org .junit .Before ;
53- import org .junit .Rule ;
5453import org .junit .Test ;
55- import org .junit .rules .ExpectedException ;
5654
5755import com .oracle .graal .python .builtins .modules .PosixModuleBuiltins .FileDescriptorConversionNode ;
5856import com .oracle .graal .python .builtins .objects .PNone ;
5957import com .oracle .graal .python .builtins .objects .frame .PFrame ;
6058import com .oracle .graal .python .builtins .objects .function .PArguments ;
6159import com .oracle .graal .python .runtime .ExecutionContext ;
6260import com .oracle .graal .python .runtime .PythonContext ;
63- import com .oracle .graal .python .runtime .exception .PException ;
6461import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
6562import com .oracle .graal .python .test .PythonTests ;
6663import com .oracle .truffle .api .RootCallTarget ;
6764import com .oracle .truffle .api .Truffle ;
6865import com .oracle .truffle .api .frame .VirtualFrame ;
6966import com .oracle .truffle .api .nodes .RootNode ;
7067
71- public class FileDescriptorConversionNodeTests {
72- @ Rule public ExpectedException expectedException = ExpectedException .none ();
68+ public class FileDescriptorConversionNodeTests extends ConversionNodeTests {
7369
7470 @ Before
7571 public void setUp () {
@@ -83,16 +79,14 @@ public void tearDown() {
8379
8480 @ Test
8581 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." );
8883 call (PNone .NONE );
8984 Assert .assertEquals (AT_FDCWD .value , call (PNone .NO_VALUE ));
9085 }
9186
9287 @ Test
9388 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." );
9690 call (PNone .NO_VALUE );
9791 }
9892
@@ -114,15 +108,13 @@ public void longFitsInt() {
114108
115109 @ Test
116110 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" );
119112 call (1L << 40 );
120113 }
121114
122115 @ Test
123116 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" );
126118 call (-1L << 40 );
127119 }
128120
@@ -133,22 +125,19 @@ public void pintFitsInt() {
133125
134126 @ Test
135127 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" );
138129 call (factory ().createInt (BigInteger .ONE .shiftLeft (100 )));
139130 }
140131
141132 @ Test
142133 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" );
145135 call (factory ().createInt (BigInteger .ONE .shiftLeft (100 ).negate ()));
146136 }
147137
148138 @ Test
149139 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." );
152141 call (evalValue ("class C:\n def __index__(self):\n return 42\n C()" ));
153142 }
154143
@@ -159,22 +148,19 @@ public void filenoOk() {
159148
160149 @ Test
161150 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" );
164152 call (evalValue ("class C:\n def fileno(self):\n return 3.14\n C()" ));
165153 }
166154
167155 @ Test
168156 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" );
171158 call (evalValue ("class C:\n def fileno(self):\n return 1 << 40\n C()" ));
172159 }
173160
174161 @ Test
175162 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." );
178164 call (3.14 );
179165 }
180166
0 commit comments