Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tpl/pytest-doctestplus"]
path = tpl/pytest-doctestplus
url = https://github.com/Erotemic/pytest-doctestplus.git
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## Version 1.3.3 - Unreleased

### Added
* doctestplus compatibility with `FLOAT_CMP`, `IGNORE_OUTPUT` directives and
`__doctest_skip__`, `__doctest_requires__` module level special vars.
* Added `deferred_output_matching` and `optional_want` config knobs, plus CLI
flags, to opt into stdlib/doctest-like output semantics without changing the
default xdoctest behavior.
Expand Down
46 changes: 33 additions & 13 deletions dev/_compare/demo_enhancements.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,40 @@ def multiple_eval_for_loops_v2():
"""


def compact_style_code():
def top_level_async():
"""
This compact style is a bit ugly, but it should still be valid python
xdoctest supports top-level async examples.

Exception:
>>> try: raise Exception # doctest: +ELLIPSIS
... except Exception: raise
Traceback (most recent call last):
...
Exception
...
>>> async def func():
>>> return 'awaited'
>>> await func()
'awaited'
"""


def prefixed_triple_quotes():
"""
>>> x = '''
>>> Prefixing every line with >>> is ok too
>>> even inside a string literal
>>> '''
>>> print(x.strip())
Prefixing every line with >>> is ok too
even inside a string literal
"""
pass


def assert_based_examples_can_ignore_stdout():
"""
>>> print('debug output that is not part of the test')
>>> value = 1 + 1
>>> assert value == 2
"""


def block_directives():
"""
>>> # xdoctest: +SKIP
>>> raise AssertionError('xdoctest skips this whole block')
"""
try:
raise Exception # NOQA
except Exception:
pass # NOQA
5 changes: 2 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@
# sys.path.insert(0, os.path.abspath('.'))

# -- Project information -----------------------------------------------------
from os.path import dirname, exists, join

import sphinx_rtd_theme
from os.path import exists
from os.path import dirname
from os.path import join


def parse_version(fpath):
Expand Down
44 changes: 44 additions & 0 deletions src/xdoctest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,30 @@ def fib(n):
doctest_callable,
doctest_module,
)
from xdoctest.directive_facade import (
BLANKLINE_MARKER,
DONT_ACCEPT_BLANKLINE,
ELLIPSIS,
ELLIPSIS_MARKER,
FLOAT_CMP,
IGNORE_EXCEPTION_DETAIL,
IGNORE_OUTPUT,
IGNORE_WHITESPACE,
IGNORE_WANT,
NORMALIZE_REPR,
NORMALIZE_WHITESPACE,
REPORT_CDIFF,
REPORT_NDIFF,
REPORT_UDIFF,
optionflags_to_runtime_state,
register_optionflag,
runtime_state_to_optionflags,
)
from xdoctest.checker_facade import (
OutputChecker,
register_checker,
resolve_checker,
)

__all__ = [
'DoctestParseError',
Expand All @@ -343,4 +367,24 @@ def fib(n):
'utils',
'docstr',
'__version__',
'BLANKLINE_MARKER',
'ELLIPSIS_MARKER',
'DONT_ACCEPT_BLANKLINE',
'NORMALIZE_WHITESPACE',
'ELLIPSIS',
'IGNORE_EXCEPTION_DETAIL',
'REPORT_UDIFF',
'REPORT_CDIFF',
'REPORT_NDIFF',
'IGNORE_WANT',
'IGNORE_OUTPUT',
'IGNORE_WHITESPACE',
'FLOAT_CMP',
'NORMALIZE_REPR',
'register_optionflag',
'runtime_state_to_optionflags',
'optionflags_to_runtime_state',
'register_checker',
'resolve_checker',
'OutputChecker',
]
Loading
Loading