Skip to content

Commit

Permalink
Add test for directive syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Aug 8, 2021
1 parent 70f2a5c commit 9174f6f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions testing/test_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ def test_multi_requires_directive():
assert stdout.count('is-skipped') == 0


def test_directive_syntax_error():
string = utils.codeblock(
'''
>>> x = 0
>>> # doctest: +REQUIRES(module:xdoctest)
>>> print('not-skipped')
>>> # doctest: +REQUIRES(badsyntax)
>>> print('is-skipped')
''')
self = doctest_example.DocTest(docsrc=string)
result = self.run(on_error='return')
assert not result['passed']
assert 'Failed to parse' in result['exc_info'][1].args[0]
assert 'line 4' in result['exc_info'][1].args[0]
stdout = ''.join(list(self.logged_stdout.values()))
assert stdout.count('not-skipped') == 1


if __name__ == '__main__':
"""
CommandLine:
Expand Down

0 comments on commit 9174f6f

Please sign in to comment.