Skip to content

Commit ec7695e

Browse files
committed
adds a bit of doctest hint on why the key and value getters are separate functions.
1 parent 1a33025 commit ec7695e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

_pytest/doctest.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,18 @@ def _get_allow_bytes_flag():
295295
return doctest.register_optionflag('ALLOW_BYTES')
296296

297297

298+
def _get_report_choices_keys():
299+
"""
300+
Returns the report choices keys. Separate function (see just below) because this is used to declare options and
301+
we can't import the doctest module at that time.
302+
"""
303+
return ('udiff', 'cdiff', 'ndiff', 'only_first_failure', 'none', )
304+
298305
def _get_report_choices():
306+
"""
307+
See `_get_report_choices_keys` to understand why this strange implementation. Be careful with order, the values
308+
order should be the same as the returned keys above.
309+
"""
299310
import doctest
300311
return dict(
301312
zip(
@@ -304,9 +315,6 @@ def _get_report_choices():
304315
)
305316
)
306317

307-
def _get_report_choices_keys():
308-
return ('udiff', 'cdiff', 'ndiff', 'only_first_failure', 'none', )
309-
310318
@pytest.fixture(scope='session')
311319
def doctest_namespace():
312320
"""

0 commit comments

Comments
 (0)