Skip to content

Commit

Permalink
Separate the option keys and value to avoid importing "doctest" (and …
Browse files Browse the repository at this point in the history
…tested things like "logging") for argument parsing (fixes #1749)
  • Loading branch information
hartym committed Jul 23, 2016
1 parent fd8e019 commit 87ca4b9
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions _pytest/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import traceback

import pytest
from _pytest._code.code import TerminalRepr, ReprFileLocation, ExceptionInfo
from _pytest._code.code import ExceptionInfo, ReprFileLocation, TerminalRepr
from _pytest.fixtures import FixtureRequest


Expand All @@ -20,7 +20,7 @@ def pytest_addoption(parser):
group.addoption("--doctest-report",
type=str.lower, default="udiff",
help="choose another output format for diffs on doctest failure",
choices=sorted(_get_report_choices().keys()),
choices=sorted(_get_report_choices_keys()),
dest="doctestreport")
group.addoption("--doctest-glob",
action="append", default=[], metavar="pat",
Expand Down Expand Up @@ -298,13 +298,14 @@ def _get_allow_bytes_flag():
def _get_report_choices():
import doctest
return dict(
udiff=doctest.REPORT_UDIFF,
cdiff=doctest.REPORT_CDIFF,
ndiff=doctest.REPORT_NDIFF,
only_first_failure=doctest.REPORT_ONLY_FIRST_FAILURE,
none=0,
zip(
_get_report_choices_keys(),
(doctest.REPORT_UDIFF, doctest.REPORT_CDIFF, doctest.REPORT_NDIFF, doctest.REPORT_ONLY_FIRST_FAILURE, 0, )
)
)

def _get_report_choices_keys():
return ('udiff', 'cdiff', 'ndiff', 'only_first_failure', 'none', )

@pytest.fixture(scope='session')
def doctest_namespace():
Expand Down

0 comments on commit 87ca4b9

Please sign in to comment.