source: java2python/jackson-t/src/test/java/tudelft/utilities/j2p/ValueTest.java@ 579

Last change on this file since 579 was 510, checked in by wouter, 19 months ago

Use SavingReporter to clean up code

File size: 1.2 KB
Line 
1package tudelft.utilities.j2p;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.File;
6import java.io.FileNotFoundException;
7import java.io.IOException;
8import java.nio.file.Paths;
9import java.util.Arrays;
10
11import org.junit.Test;
12
13import tudelft.utilities.logging.Reporter;
14import tudelft.utilities.logging.SavingReporter;
15import tudelft.utilities.pyrunner.PythonError;
16import tudelft.utilities.pyrunner.PythonVenv;
17
18public class ValueTest {
19
20 PyProgram program = PyProgram.fromDirectory(Paths.get("src/test/value"));
21
22 @Test
23 public void test() throws IOException, ClassNotFoundException {
24 System.out.println(program);
25 }
26
27 @Test
28 public void runFromZip() throws FileNotFoundException, IOException,
29 InterruptedException, PythonError {
30 File zipfile = program.getZip();
31 System.out.println("zip file at " + zipfile);
32 Reporter reporter = new SavingReporter("test");
33 PythonVenv venv = new PythonVenv(zipfile, reporter);
34 String res = venv.call(Arrays.asList("-m", "testcode.Value"), 10000);
35 System.out.println(res);
36 assertEquals(Arrays.asList("{\"value\":12.0}", "{\"value\":\"hallo\"}"),
37 Arrays.asList(res.replace(" ", "").split("\n")));
38 // as in Java but true->True and pyson inserts some extra whitespace
39 }
40}
Note: See TracBrowser for help on using the repository browser.