我正在学习Vagrant中的教程(Ubuntu18.04/ Python3.6.6)。运行pip3 install pytest-django并配置pytest.ini文件后,运行pytest返回
Command 'pytest' not found, but can be installed with:
apt install python-pytest
Please ask your administrator.
pip3 freeze输出:
pytest==3.10.0
pytest-django==3.4.3
这个装置还有别的地方吗?
我正在学习本教程中的 ,但是,当我尝试运行pytest时,我会得到以下错误:
(FlaskVenv) MacBook-Pro-de-Hugo:FlaskProject hugovillalobos$ pytest
ImportError while loading conftest '/Users/hugovillalobos/Documents/Code/FlaskProject/tests/conftest.py'.
tests/conftest.py:4: in <module>
from Flaskr import create_app
E Mo
我将按照本教程在我的项目中设置pytest。我用下面的结构和代码创建了一个新项目:
/src
/main.py
/tests
/test_pytest.py
main.py
def main():
# Bunch of stuff
print("End.")
# Entry point of the program
if (__name__ == '__main__'):
main()
test_pytest.py
import src.main as main
def test_main():
我正在通过烧瓶教程,直到部分。在编写完教程文档中列出的所有测试文件之后,我得到以下错误。
ImportError while loading conftest '/home/Desktop/flask_tutoriel/tests/conftest.py'.
tests/conftest.py:5: in <module>
from flaskr import create_app
E ModuleNotFoundError: No module named 'flaskr'
你能帮我理解一下为什么会有这个错误吗?因为您可以在项目树映
我遵循testdriven.io测试驱动开发与FastAPI和Docker教程,我被困在Pytest设置步骤。我又检查了一遍,看我错过了什么,而且一直很短。
本教程中的代码示例显示,在conftest.py中,您将获得以下from语句:
from app import main
from app.config import get_settings, Settings
首先,Pycharm告诉我它无法从上面导入任何东西。我的文件夹结构:
main.py:
import os
from fastapi import FastAPI, Depends
from tortoise.contr
我正在学习的教程。
这里是我的蔚蓝-管道.file文件:
# Python package
# Create and test a Python package on multiple Python versions.
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/python
trigg
我正在尝试遵循jetbrains上的教程(链接:),了解如何在pycharm中使用pytest,这样我就可以从事测试驱动开发了。我被困在应该为Car.py模块(此处:)中的特定函数创建测试的地方,方法是点击ctrl+shift+T,然后单击"Create new test...“。
当我点击“创建新测试...”什么都没发生。本应弹出的对话框没有出现。
我已经转到Settings>Tools>Python集成工具,并将默认的测试运行器更改为pytest。我检查了项目解释器中的包,pytest版本5.3.5是我刚刚安装的。我重新启动了pycharm。有人知道为什么对话框可能不会
我遵循了pytest的这篇教程:
但请注意,如果我创建:
class ComplexTestClass:
"""
Complex and more nuanced tests for specific sentences
"""
def test_multiple_sentences():
如果我没有在函数的顶部添加@staticmethod,我会在函数上出现一个错误,它无法与()一起拾取,并且它在我的PyCharm中以红色突出显示。
是教程(它表明不需要静态方法)错了,还是我错了,staticmethod会使我
我是PyQt的新手,但我将使用pytest和pytest-qt插件来测试我的PyQt5应用程序。我有一些用SWTBot和RCPTT在Java中进行GUI测试的经验,在那里我可以实时地看到控件和整个GUI在测试过程中发生了什么。我希望在我的新python工具中有这样的行为,但是pytest-qt似乎以某种背景方式测试GUI。所有的代码都像我预期的那样工作,但是在测试期间我看不到GUI。代码很简单,就像教程中的那样:
from tests.test import MyApp
from time import sleep
from PyQt5.QtCore import *
from PyQt5.Q
我现在正试图在一个程序上运行一些测试,但是突然我总是得到相同的错误,无论我在什么上运行它,无论是我想要测试的程序,一个基本的教程文件,一个空文件或者什么都没有。错误是:
File "/usr/local/bin/py.test", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 38, in main
config = _prepareconfig(args,
在https://testdriven.io/的教程之后,我创建了一个websocket测试来测试我的websocket连接: # tests/test_websockets.py
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.test import Client
from channels.db import database_sync_to_async
from channels.layers import get_chann
Docker文件 ARG SOURCE_IMAGE
FROM ${SOURCE_IMAGE}
# How to Mount a volume and run Pytest from
# https://stackoverflow.com/questions/35322452/is-there-a-way-to-sandbox-test-execution-with-pytest-especially-filesystem-acce
RUN adduser --disabled-password --gecos "" --uid 7357 pytest
COPY ./ /h
回溯(最近一次调用):
File "C:\Python33\Scripts\py.test-script.py", line 9, in <module>
load_entry_point('pytest==2.3.5', 'console_scripts', 'py.test')()
File "C:\Python33\lib\site-packages\pytest-2.3.5-py3.3.egg\_pytest\core.py", line 492, in main
我正在尝试写一个脚本,当发现一个特定的字符串时,它可以读取目录中的几个.xml文件(每个文件都有这个脚本),我需要它删除该字符串之后的所有内容,并将其全部替换为新内容(如果这更容易的话,可以从另一个文件中拉入)。
这里有许多行被删除/写入。
目前,我正在手动浏览文件并删除字符串之后的所有文本,然后保存文件并运行此python脚本:
import fileinput
import sys
import os
os.chdir("F:\Desktop\PyTest")
rootdir='F:\Desktop\PyTest'
for subdir, dirs, f
我用pytest编写了测试,并使用pytest命令运行它们。我看了看其他的pytest模块,然后遇到了pytest-runner。这到底是干什么用的?
模块的描述如下,请解释..。
Setup scripts can use pytest-runner to add setup.py test support for pytest runner.