Updated to version that apparently does the intended thing, unlike my original answer ...
This version works:
(ns clojure-refactoring.rename-fn-test (:use clojure.test [clojure.contrib.with-ns :only [with-ns]])) (deftest test-fn-location (create-ns 'refactoring-test-fn-rename) (with-ns 'refactoring-test-fn-rename (clojure.core/refer-clojure) (defn a [b] (inc b))) (is (not= (find-var 'refactoring-test-fn-rename/a) nil)) (remove-ns 'refactoring-test-fn-rename))
In addition, you really need to change all occurrences of _ in the namespace names to - , and vice versa - to file names.
With these changes in place, the test works fine for me. ( I didnβt even try to start it . Apparently, it still works without making changes _ / - , but in fact you need to do it! That the accepted agreement and everything is not so guaranteed to work if you do not follow his.)
For some reason, the code from the question seems to create Var a in the namespace in which the test was defined, so (find-var 'clojure-refactoring.rename-fn-test/a) returned Var, while the test failed . With the above value (find-var 'clojure-refactoring.rename-fn-test/a) returns nil as expected.
source share