source: java2python/junit-t/src/test/java/tudelft/utilities/j2p/GetResourcesTst.java@ 1277

Last change on this file since 1277 was 1219, checked in by wouter, 7 weeks ago

#368 fix heavy overloaded assertion translation , checking actual types

File size: 1.6 KB
Line 
1package tudelft.utilities.j2p;
2
3import static org.junit.Assert.assertTrue;
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;
19import tudelft.utilities.pyrunner.TestResult;
20
21/**
22 * run a program that uses clazz.getResources() including and accessing
23 * resources is tricky because (see #304)
24 * <ol>
25 * <li>the resource has to end up in the python zip file somewhere
26 * <li>pip install (which is used to install the zip file) puts it somewhere
27 * <li>our translators have to find the location
28 * <li>the file contents have to be made accessible
29 * </ol>
30 */
31public class GetResourcesTst {
32 private PyProgram program;
33
34 @Before
35 public void before() throws TranslationException {
36 program = PyProgram
37 .fromDirectories(Arrays.asList((Paths.get("resourcestest"))));
38 }
39
40 @Test
41 public void test() throws IOException, ClassNotFoundException {
42 System.out.println(program);
43 }
44
45 @Test
46 public void runFromZip() throws FileNotFoundException, IOException,
47 InterruptedException, PythonError {
48 File zipfile = program.getZip();
49 System.out.println("zip file at " + zipfile);
50 Reporter reporter = new SavingReporter("test");
51 PythonVenv venv = new PythonVenv(zipfile, reporter);
52 TestResult res = venv.test("testcode", 10000);
53 assertTrue(res.toString(), res.isSuccess());
54
55 }
56
57}
Note: See TracBrowser for help on using the repository browser.