是否有可能在PyCharm 2.7.3中启用pytest自动完成?
问题是pytest.py看起来是这样的:
...
# we are simply imported
from _pytest.core import main, UsageError, _preloadplugins
from _pytest import core as cmdline
from _pytest import __version__
_preloadplugins() # to populate pytest.* namespace so help(pytest) works
因此在自动完成列表中只有main
电流设置
使用
pytest 3.4.1
python 3.5及以上
这是我在tests/test_8_2_openpyxl.py下的测试用例
class TestSomething(unittest.TestCase):
def setUp(self):
# do setup stuff here
def tearDown(self):
# do teardown stuff here
def test_case_1(self):
# test case here...
我使用unittest样式编
我正在通过pytest做一些硒测试。下一步是开始做一些报告。我想写一些东西,让我可以运行测试,收集结果和发送电子邮件。到目前为止,我发现的最接近的事情是将测试结果写入结果日志,然后使用插件检查存在状态并从那里发送电子邮件。这是可行的,但有点麻烦,我希望有一个更优雅的方式来做它。虽然整个pytest文档都很好,但是插件文档很差--我甚至在任何地方都找不到pytest_sessionfinish,尽管它看起来很好用。
import pytest
class MyPlugin:
def pytest_sessionfinish(self, exitstatus):
if e
我知道这违反了任何需要/假定产品代码正确打包的:在某些情况下,能够在同一个文件中定义生产和测试代码(例如,在简单脚本的情况下)可能会有帮助。那么,如何使用pytest在文件中运行所有或特定的测试呢?
编辑--我的特定用例的解决方案:
<root>中的文件结构
pytest.ini
scrip_with_tests.py
pytest.ini含量
[pytest]
python_files = script_with_tests.py
script_with_tests.py含量
import pytest # this is not required, works without
假设您有如下内容:
import pytest
@pytest.fixture
def foo_fixture():
assert x == 1, "X is not 1"
if x != 1:
pytest.fail("X is not 1")
def test_foo():
assert x == 1, "X is not 1"
if x != 1:
pytest.fail("X is not 1")
有人能通过pytest.fail和assert来说明提高
我用pytest编写了测试,并使用pytest命令运行它们。我看了看其他的pytest模块,然后遇到了pytest-runner。这到底是干什么用的?
模块的描述如下,请解释..。
Setup scripts can use pytest-runner to add setup.py test support for pytest runner.