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

Last change on this file since 1358 was 889, checked in by wouter, 5 months ago

#309 create init.py files in all created subdirs

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
27 .fromDirectories(Arrays.asList((Paths.get("src/test/value"))));
28 }
29
30 @Test
31 public void test() throws IOException, ClassNotFoundException {
32 System.out.println(program);
33 }
34
35 @Test
36 public void runFromZip() throws FileNotFoundException, IOException,
37 InterruptedException, PythonError {
38 File zipfile = program.getZip();
39 System.out.println("zip file at " + zipfile);
40 Reporter reporter = new SavingReporter("test");
41 PythonVenv venv = new PythonVenv(zipfile, reporter);
42 String res = venv.call(Arrays.asList("-m", "testcode.Value"), 10000);
43 System.out.println(res);
44 assertEquals(Arrays.asList("{\"value\":12.0}", "{\"value\":\"hallo\"}"),
45 Arrays.asList(res.replace(" ", "").split("\n")));
46 // as in Java but true->True and pyson inserts some extra whitespace
47 }
48}
Note: See TracBrowser for help on using the repository browser.