Skip to content
Merged
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
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,20 @@ $ pytest --pyargs <your-package> --doctest-modules --doctest-collect=api
See [More fine-grained control](#more-fine-grained-control) section
for details on how to customize the behavior.

**NOTE** Currently, `pytest --doctest-modules` only collects doctests and skips
'regular' unit tests. This differs from the vanilla `pytest` behavior, which collects
both doctests and unit tests.
The behavior will change in a future version: `scipy-doctest==2.0` **will change the
default** to align with the vanilla `pytest`.
**NOTE** In versions 1.x, `pytest --doctest-modules` was only collecting doctests, and
skipped 'regular' unit tests. This differed from the vanilla `pytest` behavior, which
collects both doctests and unit tests.

To retain the current behavior, use the `--doctest-only-doctests` CLI option:
The behavior was changed in version 2.0: from `scipy-doctest==2.0` the default is
changed to align with the vanilla `pytest`.

To retain the previous behavior and skip 'regular' unit tests, use the
`--doctest-only-doctests` CLI option:

```
$ pytest --doctest-modules --doctest-only-doctests
$ pytest --doctest-modules --doctest-only-doctests=true
```

is unambiguous and will behave identically in the current version 1.8 and upcoming
versions of `scipy-doctest`.


### Basic usage

Expand Down
16 changes: 8 additions & 8 deletions scipy_doctest/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ def pytest_addoption(parser):
# https://github.com/pytest-dev/pytest/discussions/13435
#
# Therefore, we add a new option, --doctest-only-doctests,
# which is `true` by default, for now.
# which was `true` by default in versions 1.x.
#
# In v2.0, it the default will become `false`, so that
# In v2.0, the default is `false`, so that
#
# $ pytest --doctest-modules
#
# will run both doctests and unit tests, and the way to use the
# current behavior (only run doctests, skip unit tests) will be
# runs both doctests and unit tests, and the way to use the previous behavior
# (only run doctests, skip unit tests) is
#
# $ pytest --doctest-modules --doctest-only-doctests=true
#
group.addoption("--doctest-only-doctests",
action="store",
default="true",
default="false",
help="Whether to only collect doctests, or also collect unit tests, too.",
choices=("true", "false"),
dest="doctest_only_doctests"
Expand All @@ -71,9 +71,9 @@ def pytest_ignore_collect(collection_path, config):
This function is used to exclude the 'tests' directory and test modules when
the `--doctest-modules` option is used.
"""
# XXX: in v2.0, --doctest-modules will mean "run both doctests and unit tests",
# (consistent with vanilla pytest), and the way to retain the current behavior
# will be to add --doctest-only-doctests=true to the CLI command
# XXX: From v2.0, --doctest-modules means "run both doctests and unit tests",
# (consistent with vanilla pytest), and the way to retain the 1.x behavior
# is to add --doctest-only-doctests=true to the CLI command
if (
config.getoption("--doctest-modules") and
config.getoption("--doctest-only-doctests") == 'true'
Expand Down