代码拉取完成,页面将自动刷新
"""pytest command line options and doctest flag definition/setup."""
import doctest
import unittest.mock
NO_EXE = doctest.register_optionflag('NO_EXE')
class NoExeChecker(doctest.OutputChecker): # noqa: E302
def check_output(self, want, got, optionflags, *args, **kwargs) -> bool:
if optionflags & NO_EXE:
return True
return super().check_output(want, got, optionflags, *args, **kwargs)
unittest.mock.patch.object(doctest, 'OutputChecker', new=NoExeChecker).start() # noqa: E305
import pytest # noqa: E402
SKIP_EXE = '--skip-exe'
ONLY_EXE = '--only-exe'
def pytest_addoption(parser):
parser.addoption(SKIP_EXE, action='store_true',
help='Skip tests with pytest.mark.exe.'
' Xfail tests with pytest.mark.exe(xfail=True).'
' Skip doctests with doctest_mark_exe().'
' Xfail doctests with doctest_mark_exe(xfail=True).'
' exe marks tests requiring backend.DOT_BINARY.')
parser.addoption(ONLY_EXE, action='store_true',
help='Skip tests without pytest.mark.exe.'
' Overrides --skip-exe.'
' exe marks tests requiring backend.DOT_BINARY.')
@pytest.fixture(autouse=True)
def doctests(pytestconfig, doctest_namespace):
def doctest_mark_exe(**kwargs):
return None
if pytestconfig.getoption(SKIP_EXE):
def doctest_mark_exe(*, reason=SKIP_EXE, xfail: bool = False, **kwargs): # noqa: F811
return (pytest.xfail(reason=reason, **kwargs) if xfail
else pytest.skip(reason, **kwargs))
doctest_namespace.update(doctest_mark_exe=doctest_mark_exe)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。