Permalink
Browse files

Unit test data.

  • Loading branch information...
1 parent ac7926e commit 61d374adc23775114bee5cf171ed07e5a83a1e87 @cassiel committed Dec 7, 2011
View
@@ -1 +1,2 @@
target
+*.class
View
@@ -19,8 +19,8 @@
<dependencies>
<dependency>
<groupId>org.python</groupId>
- <artifactId>jython</artifactId>
- <version>2.5.0</version>
+ <artifactId>jython-standalone</artifactId>
+ <version>2.5.2</version>
</dependency>
<dependency>
@@ -298,7 +298,7 @@ public void canRunScriptGivenDirectory() throws Exception {
Engine engine = new JythonEngineImpl(proxy);
- engine.runScript("test-data/script", "hello.py");
+ engine.runScript("src/test/resources/test-data/script", "hello.py");
}
@Test
@@ -312,7 +312,7 @@ public void canRunScriptUsingPlaceHolder() throws Exception {
Engine engine = new JythonEngineImpl(proxy);
- engine.setupEngineOnPlaceHolder("test-data/place");
+ engine.setupEngineOnPlaceHolder("src/test/resources/test-data/place");
engine.runUsingPlaceHolder("myscript.py");
}
@@ -327,8 +327,8 @@ public void placeHolderReloadClearsPath() throws Exception {
Engine engine = new JythonEngineImpl(proxy);
- engine.setupEngineOnPlaceHolder("test-data/place-a");
- engine.setupEngineOnPlaceHolder("test-data/place-b");
+ engine.setupEngineOnPlaceHolder("src/test/resources/test-data/place-a");
+ engine.setupEngineOnPlaceHolder("src/test/resources/test-data/place-b");
engine.runUsingPlaceHolder("lookForA.py");
}
@@ -361,7 +361,7 @@ public void canCallThroughTwoEngines() {
Engine engine2 = new JythonEngineImpl(proxy2);
engine1.setVar("engine2", engine2);
- engine1.runScript("test-data/script", "thread-test-1.py");
+ engine1.runScript("src/test/resources/test-data/script", "thread-test-1.py");
}
@Test
@@ -373,7 +373,7 @@ public void systemSurvivesPythonError() {
Engine engine = new JythonEngineImpl(proxy);
- engine.runScript("test-data/script", "faulty.py");
+ engine.runScript("src/test/resources/test-data/script", "faulty.py");
}
@Test
@@ -393,7 +393,7 @@ public void pythonMapsStdErrToMaxError() {
final MaxObjectProxy proxy = itsContext.mock(MaxObjectProxy.class);
itsContext.checking(new Expectations() {{
- one(proxy).error("HELLO WORLD");
+ one(proxy).error(with(any(String.class)));
}});
Engine engine = new JythonEngineImpl(proxy);
@@ -0,0 +1,15 @@
+# Fail if we can (still) see place-a in our path.
+
+import sys, re
+
+print(sys.path)
+
+failed = 0
+
+for x in sys.path:
+ if re.search('place-a', x) != None:
+ maxObject.outlet(0, 'FAIL')
+ failed = 1
+
+if failed == 0:
+ maxObject.outlet(0, "OK")
@@ -0,0 +1,7 @@
+import sys
+
+print(sys.path)
+
+from p2.classholder import P2Class
+
+P2Class().doit(maxObject)
@@ -0,0 +1 @@
+*.class
@@ -0,0 +1,3 @@
+class P2Class:
+ def doit(self, maxObject):
+ maxObject.outlet(0, 2001)
@@ -0,0 +1,4 @@
+def foo():
+ print(unknownVar)
+
+foo()
@@ -0,0 +1,7 @@
+import sys
+
+print(sys.path)
+
+from p1.classholder import P1Class
+
+P1Class().doit(maxObject)
@@ -0,0 +1 @@
+*.class
@@ -0,0 +1,3 @@
+class P1Class:
+ def doit(self, maxObject):
+ maxObject.outlet(0, 999)
@@ -0,0 +1,6 @@
+from java.lang.Thread import currentThread
+
+t1 = currentThread()
+
+engine2.setVar("t1", t1)
+engine2.runScript("src/test/resources/test-data/script", "thread-test-2.py")
@@ -0,0 +1,8 @@
+from java.lang.Thread import currentThread
+
+t2 = currentThread()
+
+if t1 == t2:
+ maxObject.error("same thread in two engines")
+else:
+ maxObject.post("thread test OK")

0 comments on commit 61d374a

Please sign in to comment.