Skip to content

Commit 4e647a2

Browse files
committed
ENH: adding doctest-remote-data-all directive
1 parent d620c96 commit 4e647a2

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

pytest_doctestplus/plugin.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ class DocTestParserPlus(doctest.DocTestParser):
397397
398398
- ``.. doctest-remote-data::``: Skip the next doctest chunk if
399399
--remote-data is not passed.
400+
401+
- ``.. doctest-remote-data-all::``: Skip all subsequent doctest
402+
chunks if --remote-data is not passed.
400403
"""
401404

402405
def parse(self, s, name=None):
@@ -429,15 +432,24 @@ def parse(self, s, name=None):
429432
required_all = []
430433
skip_next = False
431434
lines = entry.strip().splitlines()
435+
432436
requires_all_match = [re.match(
433437
fr'{comment_char}\s+doctest-requires-all\s*::\s+(.*)', x) for x in lines]
434438
if any(requires_all_match):
435-
required_all = [re.split(r'\s*[,\s]\s*', match.group(1)) for match in requires_all_match if match][0]
436-
439+
required_all = [re.split(r'\s*[,\s]\s*', match.group(1))
440+
for match in requires_all_match if match][0]
437441
required_modules_all = DocTestFinderPlus.check_required_modules(required_all)
442+
if not required_modules_all:
443+
skip_all = True
444+
continue
445+
446+
if config.getoption('remote_data', 'none') != 'any':
447+
if any(re.match(fr'{comment_char} doctest-remote-data-all::', x.strip())
448+
for x in lines):
449+
skip_all = True
450+
continue
438451

439-
if any(re.match(
440-
f'{comment_char} doctest-skip-all', x.strip()) for x in lines) or not required_modules_all:
452+
if any(re.match(f'{comment_char} doctest-skip-all', x.strip()) for x in lines):
441453
skip_all = True
442454
continue
443455

pytest_doctestplus/sphinx/doctestplus.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def setup(app):
4848
app.add_directive('doctest-skip-all', DoctestSkipDirective)
4949
app.add_directive('doctest', DoctestSkipDirective, override=True)
5050
app.add_directive('doctest-remote-data', DoctestSkipDirective)
51+
app.add_directive('doctest-remote-data-all', DoctestSkipDirective)
5152
# Code blocks that use this directive will not appear in the generated
5253
# documentation. This is intended to hide boilerplate code that is only
5354
# useful for testing documentation using doctest, but does not actually

0 commit comments

Comments
 (0)