gpt4 book ai didi

clojure - 热修复 "WARNING: any? already refers to: #' clojure.core/any?在命名空间 : leiningen. midje 中,被替换为:#'leiningen.midje/any?"

转载 作者:行者123 更新时间:2023-12-02 16:56:07 25 4
gpt4 key购买 nike

我正在尝试使用 midje 框架在 leiningen 的 compojure 模板 (lein new compojure financeiro) 中运行测试并收到警告:

lein midje
WARNING: any? already refers to: #'clojure.core/any? in namespace: leiningen.midje, being replaced by: #'leiningen.midje/any?
nil
All checks (3) succeeded.

我的测试代码handler_test.clj:

(ns financeiro.handler-test
(:require
; [clojure.test :refer :all]
[midje.sweet :refer :all]
[ring.mock.request :as mock]
[financeiro.handler :refer :all]))

; (deftest test-app
; (testing "main route"
; (let [response (app (mock/request :get "/"))]
; (is (= (:status response) 200))
; (is (= (:body response) "Hello World"))))

; (testing "not-found route"
; (let [response (app (mock/request :get "/invalid"))]
; (is (= (:status response) 404)))))

(facts "'Hello World' main route"
(fact "response status is 200"
(let [response (app (mock/request :get "/"))]
(:status response)=> 200))

(fact "body text is 'Hello World'"
(let [response (app (mock/request :get "/"))]
(:body response)=> "Hello World")))

(facts "not-found route"
(fact "response status is 404"
(let [response(app (mock/request :get "/invalid"))]
(:status response)=> 404)))

我的项目文件project.clj:

(defproject financeiro "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:min-lein-version "2.0.0"
:dependencies [
[org.clojure/clojure "1.10.0"]
[compojure "1.6.1"]
[ring/ring-defaults "0.3.2"]
]
:plugins [
[lein-ring "0.12.5"]
]
:ring {
:handler financeiro.handler/app
}
:profiles {
:dev {
:dependencies [
[javax.servlet/servlet-api "2.5"]
[ring/ring-mock "0.3.2"]
[midje "1.9.8"]
]
:plugins [
[lein-midje "3.2.1"]
]
}
}
)

当我使用 clojure.test (lein test) 运行默认测试时,我没有收到警告,但是当我使用 midje.sweet 运行时> (lein midje) 我收到关于'namespace: leiningen.midje''replace #'clojure.core/any?到#'leiningen.midje/any?',我在网上搜索解决方案,但我没有找到这个特定警告 (leiningen/compojure/midje),我是clojure 和 midje 的初学者。我现在正在学习。我可以在哪个文件中替换这个命名空间?有没有简单的解决方案来删除此警告?或者这是框架 midje 中的错误?

这不会干扰测试的执行,但每次运行测试时都会看到此消息很烦人。

注意:我也尝试过之前版本的midje [midje "1.9.6"],但是没有成功!

最佳答案

此特定问题已解决 in this Pull Request .

对于一般情况,您可以通过从 clojure.core 之外的另一个 namespace 中排除(= 取消引用)您想要的符号来消除此警告(当它来自您的代码时)

这是一个来自不同上下文的示例:

警告

(ns urbest.apheleia.system.typography
(:require [garden.units :refer [rem]]))
WARNING: rem already refers to: #'clojure.core/rem in namespace: urbest.apheleia.system.typography, being replaced by: #'garden.units/rem

不再有警告

(ns urbest.apheleia.system.typography
(:refer-clojure :exclude [rem])
(:require [garden.units :refer [rem]]))

关于clojure - 热修复 "WARNING: any? already refers to: #' clojure.core/any?在命名空间 : leiningen. midje 中,被替换为:#'leiningen.midje/any?",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56345030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com