Skip to content

Commit a778870

Browse files
committed
use midje, add some tests
1 parent 1a8ee20 commit a778870

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

project.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:description "Improve seamlessness of Clojure Jython interop."
33
:dependencies [[org.clojure/clojure "1.3.0"]
44
[org.python/jython-standalone "2.5.2"]]
5-
:main clojure-python.core)
5+
:dev-dependencies [[midje "1.3.0-RC4"]]
6+
:main clojure-python.core)

test/clojure_python/core_test.clj

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/clojure_python/t_core.clj

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
(ns clojure-python.t-core
2+
(:use midje.sweet)
3+
(:require [clojure-python.core :as base]))
4+
5+
(fact "append-paths adds the path to system path"
6+
(binding [base/*interp* (org.python.util.PythonInterpreter.)]
7+
(-> (#'base/append-paths! ["test/clojure_python/"])
8+
.getLocals
9+
(.__getitem__ "sys")
10+
.path
11+
set
12+
(get "test/clojure_python/")))
13+
=>
14+
"test/clojure_python/")
15+
16+
(fact "init sets *interp* root binding (but only once)"
17+
(do
18+
(base/init {:libpaths ["test/clojure_python/"]})
19+
(class base/*interp*))
20+
=>
21+
org.python.util.PythonInterpreter
22+
23+
(do
24+
(base/init {:libpaths ["test/clojure_python/"]})
25+
(class base/*interp*))
26+
=>
27+
(do
28+
(base/init {:libpaths ["test/clojure_python/"]})
29+
(class base/*interp*)))
30+
31+
(fact "with-interpreter dynamically binds a new interpreter environment"
32+
(base/with-interpreter
33+
{:libpaths ["test/clojure_python/"]}
34+
base/*interp*)
35+
=not=>
36+
(base/with-interpreter
37+
{:libpaths ["test/clojure_python/"]}
38+
base/*interp*))

0 commit comments

Comments
 (0)