Separate the option keys and value to avoid importing "doctest" (and tested things like "logging") for argument parsing (fixes #1749)
This commit is contained in:
parent
fd8e019cc1
commit
87ca4b95fb
|
@ -4,7 +4,7 @@ from __future__ import absolute_import
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest._code.code import TerminalRepr, ReprFileLocation, ExceptionInfo
|
from _pytest._code.code import ExceptionInfo, ReprFileLocation, TerminalRepr
|
||||||
from _pytest.fixtures import FixtureRequest
|
from _pytest.fixtures import FixtureRequest
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ def pytest_addoption(parser):
|
||||||
group.addoption("--doctest-report",
|
group.addoption("--doctest-report",
|
||||||
type=str.lower, default="udiff",
|
type=str.lower, default="udiff",
|
||||||
help="choose another output format for diffs on doctest failure",
|
help="choose another output format for diffs on doctest failure",
|
||||||
choices=sorted(_get_report_choices().keys()),
|
choices=sorted(_get_report_choices_keys()),
|
||||||
dest="doctestreport")
|
dest="doctestreport")
|
||||||
group.addoption("--doctest-glob",
|
group.addoption("--doctest-glob",
|
||||||
action="append", default=[], metavar="pat",
|
action="append", default=[], metavar="pat",
|
||||||
|
@ -298,13 +298,14 @@ def _get_allow_bytes_flag():
|
||||||
def _get_report_choices():
|
def _get_report_choices():
|
||||||
import doctest
|
import doctest
|
||||||
return dict(
|
return dict(
|
||||||
udiff=doctest.REPORT_UDIFF,
|
zip(
|
||||||
cdiff=doctest.REPORT_CDIFF,
|
_get_report_choices_keys(),
|
||||||
ndiff=doctest.REPORT_NDIFF,
|
(doctest.REPORT_UDIFF, doctest.REPORT_CDIFF, doctest.REPORT_NDIFF, doctest.REPORT_ONLY_FIRST_FAILURE, 0, )
|
||||||
only_first_failure=doctest.REPORT_ONLY_FIRST_FAILURE,
|
)
|
||||||
none=0,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _get_report_choices_keys():
|
||||||
|
return ('udiff', 'cdiff', 'ndiff', 'only_first_failure', 'none', )
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def doctest_namespace():
|
def doctest_namespace():
|
||||||
|
|
Loading…
Reference in New Issue