Skip to content

Commit 2a4eba9

Browse files
authored
Merge pull request #207 from scipy/doctest-only-doctests-toggle
Toggle the `--doctest-only-doctests` option
2 parents 01e8250 + 708753d commit 2a4eba9

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,20 @@ $ pytest --pyargs <your-package> --doctest-modules --doctest-collect=api
151151
See [More fine-grained control](#more-fine-grained-control) section
152152
for details on how to customize the behavior.
153153

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

160-
To retain the current behavior, use the `--doctest-only-doctests` CLI option:
158+
The behavior was changed in version 2.0: from `scipy-doctest==2.0` the default is
159+
changed to align with the vanilla `pytest`.
160+
161+
To retain the previous behavior and skip 'regular' unit tests, use the
162+
`--doctest-only-doctests` CLI option:
161163

162164
```
163-
$ pytest --doctest-modules --doctest-only-doctests
165+
$ pytest --doctest-modules --doctest-only-doctests=true
164166
```
165167

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

170169
### Basic usage
171170

scipy_doctest/plugin.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ def pytest_addoption(parser):
3333
# https://github.com/pytest-dev/pytest/discussions/13435
3434
#
3535
# Therefore, we add a new option, --doctest-only-doctests,
36-
# which is `true` by default, for now.
36+
# which was `true` by default in versions 1.x.
3737
#
38-
# In v2.0, it the default will become `false`, so that
38+
# In v2.0, the default is `false`, so that
3939
#
4040
# $ pytest --doctest-modules
4141
#
42-
# will run both doctests and unit tests, and the way to use the
43-
# current behavior (only run doctests, skip unit tests) will be
42+
# runs both doctests and unit tests, and the way to use the previous behavior
43+
# (only run doctests, skip unit tests) is
4444
#
4545
# $ pytest --doctest-modules --doctest-only-doctests=true
4646
#
4747
group.addoption("--doctest-only-doctests",
4848
action="store",
49-
default="true",
49+
default="false",
5050
help="Whether to only collect doctests, or also collect unit tests, too.",
5151
choices=("true", "false"),
5252
dest="doctest_only_doctests"
@@ -71,9 +71,9 @@ def pytest_ignore_collect(collection_path, config):
7171
This function is used to exclude the 'tests' directory and test modules when
7272
the `--doctest-modules` option is used.
7373
"""
74-
# XXX: in v2.0, --doctest-modules will mean "run both doctests and unit tests",
75-
# (consistent with vanilla pytest), and the way to retain the current behavior
76-
# will be to add --doctest-only-doctests=true to the CLI command
74+
# XXX: From v2.0, --doctest-modules means "run both doctests and unit tests",
75+
# (consistent with vanilla pytest), and the way to retain the 1.x behavior
76+
# is to add --doctest-only-doctests=true to the CLI command
7777
if (
7878
config.getoption("--doctest-modules") and
7979
config.getoption("--doctest-only-doctests") == 'true'

0 commit comments

Comments
 (0)