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

Last change on this file since 826 was 744, checked in by wouter, 11 months ago

#254 PyProgram now throws TranslationException. Ignore broken test in tudunit-t

File size: 1.4 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.Before;
12import org.junit.Test;
13
14import tudelft.utilities.j2p.t.TranslationException;
15import tudelft.utilities.logging.Reporter;
16import tudelft.utilities.logging.SavingReporter;
17import tudelft.utilities.pyrunner.PythonError;
18import tudelft.utilities.pyrunner.PythonVenv;
19
20public class ValueTest {
21
22 PyProgram program;
23
24 @Before
25 public void before() throws TranslationException {
26 program = PyProgram.fromDirectory(Paths.get("src/test/value"));
27 }
28
29 @Test
30 public void test() throws IOException, ClassNotFoundException {
31 System.out.println(program);
32 }
33
34 @Test
35 public void runFromZip() throws FileNotFoundException, IOException,
36 InterruptedException, PythonError {
37 File zipfile = program.getZip();
38 System.out.println("zip file at " + zipfile);
39 Reporter reporter = new SavingReporter("test");
40 PythonVenv venv = new PythonVenv(zipfile, reporter);
41 String res = venv.call(Arrays.asList("-m", "testcode.Value"), 10000);
42 System.out.println(res);
43 assertEquals(Arrays.asList("{\"value\":12.0}", "{\"value\":\"hallo\"}"),
44 Arrays.asList(res.replace(" ", "").split("\n")));
45 // as in Java but true->True and pyson inserts some extra whitespace
46 }
47}
Note: See TracBrowser for help on using the repository browser.