diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index 6c0327fab02..7e6ce75a6ac 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -38,7 +38,7 @@ logger = logging.getLogger(__name__) blankline_re = re.compile(r'^\s*', re.MULTILINE) -doctestopt_re = re.compile(r'#\s*doctest:.+$', re.MULTILINE) +doctestopt_re = re.compile(r'\s*#\s*doctest:.+$', re.MULTILINE) def is_allowed_version(spec: str, version: str) -> bool: diff --git a/tests/test_transforms/test_transforms_post_transforms_code.py b/tests/test_transforms/test_transforms_post_transforms_code.py index a4243fb85bc..381f4ac5980 100644 --- a/tests/test_transforms/test_transforms_post_transforms_code.py +++ b/tests/test_transforms/test_transforms_post_transforms_code.py @@ -15,6 +15,7 @@ def test_trim_doctest_flags_html(app): assert 'QUUX' not in result assert 'CORGE' not in result assert 'GRAULT' in result + assert 'now() \n' not in result @pytest.mark.sphinx(