我的项目中有一些twisted.trial测试,即从twisted.trial.unittest.TestCase继承的测试。
我需要通过一些测试选项,特别是-- twisted.trial命令行实用程序的反应堆选项。有什么办法可以让我把它传递给化脓性试验吗?我的想法是:我在pytest.ini中添加了一些东西,而pytest将以某种方式使用这个选项启动我的试用单元测试用例。现在有可能吗?
样本来复制这个。进行以下单元测试:
# test_reactor.py
from twisted.trial.unittest import TestCase
class CrawlTestCase(TestCase):
def test_if_correct_reactor(self):
from twisted.internet import reactor
from twisted.internet.asyncioreactor import AsyncioSelectorReactor
assert isinstance(reactor, AsyncioSelectorReactor)现在试着用反应堆标志运行它
python -m twisted.trial --reactor=asyncio test_reactor
test_reactor
CrawlTestCase
test_if_correct_reactor ... [OK]
-------------------------------------------------------------------------------
Ran 1 tests in 0.042s
PASSED (successes=1)现在运行它没有--反应堆标志
python -m twisted.trial test_reactor
test_reactor
CrawlTestCase
test_if_correct_reactor ... [ERROR]
===============================================================================
[ERROR]
Traceback (most recent call last):
File "/home/pawel/.../test_reactor.py", line 8, in test_if_correct_reactor
assert isinstance(reactor, AsyncioSelectorReactor)
builtins.AssertionError:
test_reactor.CrawlTestCase.test_if_correct_reactor
-------------------------------------------------------------------------------
Ran 1 tests in 0.081s
FAILED (errors=1)现在用pytest运行它
py.test test_reactor.py
============================================================================================================ test session starts =============================================================================================================
platform linux -- Python 3.9.4, pytest-6.2.3, py-1.11.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/pawel/../aaomw, configfile: pytest.ini
plugins: Faker-8.1.3, hypothesis-6.10.1, benchmark-3.4.1
collected 1 item
test_reactor.py F 问题是:我怎样才能把一些东西传递给化脓性试验,这样它才能通过试验呢?我能在pytest.ini里放点什么让反应堆通过扭曲的试验吗?
如果我试图做的是不可能的,请提供证据证明这是不可能的,这也可能是被接受的答案,也许需要在pytest中改变一些东西来使这种事情成为可能。
发布于 2021-12-31 13:19:06
安装热扭插件后,我得到-反应堆标志和一个正确的选项安装和发射反应堆.
https://stackoverflow.com/questions/70542251
复制相似问题