From ec7695e15d26d6cf6610212b2e69d4d5fb034dd7 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Sat, 23 Jul 2016 15:19:18 +0200 Subject: [PATCH] adds a bit of doctest hint on why the key and value getters are separate functions. --- _pytest/doctest.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/_pytest/doctest.py b/_pytest/doctest.py index 59846a21d4d..e4e02853551 100644 --- a/_pytest/doctest.py +++ b/_pytest/doctest.py @@ -295,7 +295,18 @@ def _get_allow_bytes_flag(): return doctest.register_optionflag('ALLOW_BYTES') +def _get_report_choices_keys(): + """ + Returns the report choices keys. Separate function (see just below) because this is used to declare options and + we can't import the doctest module at that time. + """ + return ('udiff', 'cdiff', 'ndiff', 'only_first_failure', 'none', ) + def _get_report_choices(): + """ + See `_get_report_choices_keys` to understand why this strange implementation. Be careful with order, the values + order should be the same as the returned keys above. + """ import doctest return dict( zip( @@ -304,9 +315,6 @@ def _get_report_choices(): ) ) -def _get_report_choices_keys(): - return ('udiff', 'cdiff', 'ndiff', 'only_first_failure', 'none', ) - @pytest.fixture(scope='session') def doctest_namespace(): """