@@ -192,8 +192,15 @@ public static void assertPrints(String expected, Path scriptName) {
192192 public static void assertPrints (String expected , String code ) {
193193 final ByteArrayOutputStream byteArray = new ByteArrayOutputStream ();
194194 final PrintStream printStream = new PrintStream (byteArray );
195- String source = code ;
196- PythonTests .runScript (new String [0 ], source , printStream , System .err );
195+ PythonTests .runScript (new String [0 ], code , printStream , System .err );
196+ String result = byteArray .toString ().replaceAll ("\r \n " , "\n " );
197+ assertEquals (expected .replaceAll (" at 0x[0-9a-f]*>" , " at 0xabcd>" ), result .replaceAll (" at 0x[0-9a-f]*>" , " at 0xabcd>" ));
198+ }
199+
200+ public static void assertPrints (String expected , org .graalvm .polyglot .Source code ) {
201+ final ByteArrayOutputStream byteArray = new ByteArrayOutputStream ();
202+ final PrintStream printStream = new PrintStream (byteArray );
203+ PythonTests .runScript (new String [0 ], code , printStream , System .err );
197204 String result = byteArray .toString ().replaceAll ("\r \n " , "\n " );
198205 assertEquals (expected .replaceAll (" at 0x[0-9a-f]*>" , " at 0xabcd>" ), result .replaceAll (" at 0x[0-9a-f]*>" , " at 0xabcd>" ));
199206 }
@@ -311,6 +318,15 @@ public static void runScript(String[] args, String source, OutputStream out, Out
311318 }
312319 }
313320
321+ public static void runScript (String [] args , org .graalvm .polyglot .Source source , OutputStream out , OutputStream err ) {
322+ try {
323+ enterContext (args );
324+ context .eval (source );
325+ } finally {
326+ flush (out , err );
327+ }
328+ }
329+
314330 public static void runScript (String [] args , String source , OutputStream out , OutputStream err , Runnable cb ) {
315331 try {
316332 enterContext (args );
0 commit comments