Skip to content

Commit

Permalink
add tests for py module and function importing
Browse files Browse the repository at this point in the history
  • Loading branch information
rplevy committed Dec 14, 2011
1 parent 1dd9ee7 commit ba6d25a
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions test/clojure_python/t_core.clj
Expand Up @@ -28,11 +28,43 @@
(base/init {:libpaths ["test/clojure_python/"]})
(class base/*interp*)))


(defmacro with-test-interp [& body]
`(base/with-interpreter
{:libpaths ["test/clojure_python/"]}
~@body))

(fact "with-interpreter dynamically binds a new interpreter environment"
(base/with-interpreter
{:libpaths ["test/clojure_python/"]}
base/*interp*)
(with-test-interp base/*interp*)
=not=>
(base/with-interpreter
{:libpaths ["test/clojure_python/"]}
base/*interp*))
(with-test-interp base/*interp*))

(fact "importing python modules works"
(with-test-interp
(base/py-import example)
(class example))
=>
org.python.core.PyStringMap)

(fact "importing python functions works"
(with-test-interp
(base/py-import example)
(base/import-fn example hello)
(fn? hello))
=>
true)

(fact "calling python functions works"
(with-test-interp
(base/py-import example)
(base/import-fn example hello)
(hello "world"))
=>
"hello, world how are you."

(with-test-interp
(base/py-import example)
((base/py-fn example hello)
"person"))
=>
"hello, person how are you.")

0 comments on commit ba6d25a

Please sign in to comment.