зеркало из https://github.com/mozilla/jydoop.git
run tests via our wrapper
This commit is contained in:
Родитель
a957b625dc
Коммит
62ae5c759f
2
Makefile
2
Makefile
|
@ -16,7 +16,7 @@ TEST_PY=test.py
|
|||
all: driver.jar
|
||||
|
||||
check: driver.jar
|
||||
java -cp driver.jar:$(CP) org.python.util.jython $(TEST_PY)
|
||||
java -cp driver.jar:$(CP) org.mozilla.jydoop.PythonWrapper $(TEST_PY)
|
||||
|
||||
run: driver.jar
|
||||
java -cp driver.jar:$(CP) org.mozilla.jydoop.$(TASK)
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.python.core.PyType;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.net.URL;
|
||||
import java.net.JarURLConnection;
|
||||
|
||||
|
@ -48,7 +49,9 @@ public class PythonWrapper {
|
|||
File f;
|
||||
|
||||
try {
|
||||
if (url.getProtocol().equals("file")) {
|
||||
if (url == null) {
|
||||
f = new File(path);
|
||||
} else if (url.getProtocol().equals("file")) {
|
||||
f = new File(url.toURI());
|
||||
} else if (url.getProtocol().equals("jar")) {
|
||||
JarURLConnection j = (JarURLConnection) url.openConnection();
|
||||
|
@ -84,9 +87,14 @@ public class PythonWrapper {
|
|||
|
||||
// Get the the script path from our loader
|
||||
URL scripturl = this.getClass().getResource("/" + pathname);
|
||||
InputStream pythonstream = scripturl.openStream();
|
||||
InputStream pythonstream = scripturl != null ? scripturl.openStream() : new FileInputStream(pathname);
|
||||
interp.execfile(pythonstream, pathname);
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws IOException {
|
||||
new PythonWrapper(args[0]);
|
||||
}
|
||||
|
||||
public PyObject getFunction(String name) {
|
||||
return interp.get(name.intern());
|
||||
}
|
||||
|
|
3
test.py
3
test.py
|
@ -123,4 +123,5 @@ class TestResource(unittest.TestCase):
|
|||
self.assertIsNotNone(jydoop.getResource("scripts/jydoop.py"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
"""For some reason sys.exit(0) causes Jython to get angry when run from PythonWrapper"""
|
||||
unittest.main(exit=False)
|
||||
|
|
Загрузка…
Ссылка в новой задаче