- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Docker 中运行一个 Django 应用程序,一切正常,但是当我尝试运行测试时,它失败了,错误非常模糊。
运行 docker-compose run djangoapp coverage run -m pytest
结果:
Creating djangoapp_run ... done ================================================= test session starts ==================================================
platform linux -- Python 3.8.5, pytest-6.2.1, py-1.10.0, pluggy-0.13.1
rootdir: /
collected 0 items / 1 error
======================================================== ERRORS ========================================================
____________________________________________ ERROR collecting test session _____________________________________________
usr/local/lib/python3.8/dist-packages/_pytest/runner.py:311: in from_call
result: Optional[TResult] = func()
usr/local/lib/python3.8/dist-packages/_pytest/runner.py:341: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
usr/local/lib/python3.8/dist-packages/_pytest/main.py:710: in collect
for x in self._collectfile(path):
usr/local/lib/python3.8/dist-packages/_pytest/main.py:546: in _collectfile
assert (
E AssertionError: local('/dev/console') is not a file (isdir=False, exists=True, islink=False)
=============================================== short test summary info ================================================
ERROR - AssertionError: local('/dev/console') is not a file (isdir=False, exists=True, islink=False)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=================================================== 1 error in 0.33s ===================================================
docker 组成:
version: '3'
services:
djangoapp:
build: .
container_name: djangoapp
ports:
- '8000:80'
- '1433:1433'
volumes:
- ./djangoapp:/var/www/html/djangoapp
environment:
- PYTHONUNBUFFERED=0
最佳答案
pytest
递归遍历,docker 中的默认工作目录是 /
.将这些组合起来......设置直接正确工作!
...
environment:
- PYTHONUNBUFFERED=0
working_dir: /var/www/html/djangoapp
...
关于django - Pytest 不能与 Django 和 Docker 一起使用 - AssertionError : local ('/dev/console' ) is not a file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65394782/
我在一个Spring Boot应用程序中有以下路线。并进行以下测试。第二个测试的目的是验证如果将消息“{}”发送到DIRECT:LOG终结点,它将超出To(Bean-validator://check
这是我的简单 test.py 脚本: import argparse parser = argparse.ArgumentParser('A long string that goes on and
我在Android Studio的另一台计算机上打开我的Kotlin项目,并在事件日志中遇到错误: AssertionError: Root package must be initialized R
我在redux (redux@3.7.2) 中使用combineReducer 方法时遇到错误。当我只使用一个 reducer 时,相同的代码将起作用。 Running code here 代码 co
我目前正在对我的 Controller 的一个方法进行单元测试。只是尝试测试该方法是否返回正确的字符串。 @RequestMapping(value = "/createTestscenario",
我收到错误: java.lang.AssertionError: expected: learning.java.advancedoop2.MyComplex but was: learning.ja
这个问题在这里已经有了答案: How can I check if two ArrayList differ, I don't care what's changed (6 个答案) 关闭 7 年前
我正在准备 OCP 7,我在其中一本证书书上遇到了这篇文章。 To discourage you from trying to substitute an assertion for an excep
我有一个 index.js 文件,它实现了一个 forEach 助手,如下所示: var images = [ { height: 10, width: 30 }, { height: 20,
作为实验,我 try catch 失败的断言。 try: assert 1==2 except Exception as e: print e 为什么没有显示? 最佳答案 >>> try: asser
我在 django 中创建了一个调用函数的命令。该函数执行 django orm 调用: def get_notes(): notes = Note.objects.filter(number
我有一个用户类和一个主题类。用户类可以创建一个主题,将一个主题添加到主题的字典中,并且应该能够返回主题的字典。我是 python 的新手,所以我在 python 逻辑/语法方面遇到了问题 class
我正在尝试创建一个基于用户身份验证限制结果的 View 。出于某种原因,列表切片总是导致 AssertionError Cannot filter a query once a slice has b
我正在使用带有注释处理器的内部 sun API (com.sun.tools.javac) 修改现有类。我能够使用以下代码生成 MethodDecl 并将其添加到 ClassDecl: JCTree.
这是原代码 //@author Brian Goetz and Tim Peierls @ThreadSafe public class SafePoint { @GuardedBy("thi
我能够访问 PasswordChangeSerializer 的 validate() 函数的 user_queryset,但是我仍然收到此错误: assert value is not None,
我正在尝试从破解编码面试中回答以下问题。下面的代码是 GitHub 上一个项目的一部分,here . Given a binary search tree, design an algorithm w
我正在使用 IBM Bluemix 为学校项目创建 Web 服务。 我设置了本地主机来运行我的代码,但是当我在 Windows 10 命令提示符中键入“npm start”时,我遇到了“assert.
将 tf.Dataset 传递到 tf.Keras 模型的 fit() 时,我收到 AssertionError方法。 我正在使用tensorflow==2.0.0。 我检查了我的数据集是否有效: #
我有一个异步回调,我为此编写了一个 junit 测试用例。我正在遵循 CountDownLatch 方法。如果回调失败,我必须使测试用例失败。这是我的代码 lock = new CountDo
我是一名优秀的程序员,十分优秀!