Skip to content

Commit 5436690

Browse files
authored
INTPYTHON-380 Add doctests (#177)
1 parent 6c71a89 commit 5436690

File tree

9 files changed

+16
-168
lines changed

9 files changed

+16
-168
lines changed

Diff for: .github/workflows/test-python.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ jobs:
3232
- uses: extractions/setup-just@v2
3333
- run: just install
3434
- run: just lint
35-
- run: just docs
3635
- run: uv run pre-commit run --hook-stage manual --all-files
36+
- run: just docs
37+
- run: just doctest
3738
build:
3839
runs-on: ${{ matrix.os }}
3940
strategy:

Diff for: CONTRIBUTING.md

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ actual bugs and improvement requests.
2929
- All new features must include a test. Flask-PyMongo is tested against a
3030
matrix of all supported versions of Flask, PyMongo, and MongoDB, so tests
3131
ensure that your change works for all users.
32-
- There is also a `style` build. Please ensure your code conforms to
33-
Flask-PyMongo's style rules with `tox -e style`
3432
- Use [Sphinx](http://www.sphinx-doc.org/en/master/)-style docstrings
3533

3634

Diff for: docs/Makefile

-153
This file was deleted.

Diff for: docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
# Add any Sphinx extension module names here, as strings. They can be extensions
3232
# coming with Sphinx (named "sphinx.ext.*") or your custom ones.
33-
extensions = ["sphinx.ext.intersphinx", "sphinx.ext.autodoc"]
33+
extensions = ["sphinx.ext.intersphinx", "sphinx.ext.autodoc", "sphinx.ext.doctest"]
3434

3535
# Add any paths that contain templates here, relative to this directory.
3636
templates_path = ["_templates"]

Diff for: docs/index.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ versions.
6565

6666
Flask-PyMongo is tested against `supported versions
6767
<https://www.mongodb.com/support-policy>`_ of MongoDB, and Python
68-
and 3.8+. For the exact list of version combinations that are tested and
69-
known to be compatible, see the `envlist` in `tox.ini
70-
<https://github.com/dcrosta/flask-pymongo/blob/master/tox.ini>`_.
68+
and 3.9+. For the exact list of version combinations that are tested and
69+
known to be compatible.
7170

7271

7372
Helpers
@@ -110,7 +109,7 @@ constructor. These are passed directly through to the underlying
110109
By default, Flask-PyMongo sets the ``connect`` keyword argument to
111110
``False``, to prevent PyMongo from connecting immediately. PyMongo
112111
itself `is not fork-safe
113-
<http://api.mongodb.com/python/current/faq.html#is-pymongo-fork-safe>`_,
112+
<https://www.mongodb.com/docs/languages/python/pymongo-driver/current/faq/#is-pymongo-fork-safe->`_,
114113
and delaying connection until the app is actually used is necessary to
115114
avoid issues. If you wish to change this default behavior, pass
116115
``connect=True`` as a keyword argument to ``PyMongo``.

Diff for: docs/requirements.txt

-2
This file was deleted.

Diff for: examples/wiki/wiki.py

-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,4 @@ def save_upload(filename: str) -> str | Response:
8989

9090

9191
if __name__ == "__main__":
92-
import doctest
93-
94-
doctest.testmod()
9592
app.run(debug=True)

Diff for: flask_pymongo/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def init_app(self, app: Flask, uri: str | None = None, *args: Any, **kwargs: Any
109109
database_name = parsed_uri["database"]
110110

111111
# Try to delay connecting, in case the app is loaded before forking, per
112-
# http://api.mongodb.com/python/current/faq.html#is-pymongo-fork-safe
112+
# https://www.mongodb.com/docs/languages/python/pymongo-driver/current/faq/#is-pymongo-fork-safe-
113113
kwargs.setdefault("connect", False)
114114
if DriverInfo is not None:
115115
kwargs.setdefault("driver", DriverInfo("Flask-PyMongo", __version__))

Diff for: justfile

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
docs_build := "docs/_build"
2+
sphinx_opts:= "-d " + docs_build + "/doctrees docs"
3+
14
# Default target executed when no arguments are given.
25
[private]
36
default:
@@ -15,7 +18,12 @@ lint:
1518
uv run pre-commit run ruff-format --files
1619

1720
docs:
18-
uv run sphinx-build -T -b html docs docs/_build
21+
uv run sphinx-build -T -b html {{sphinx_opts}} {{docs_build}}
22+
23+
doctest:
24+
uv run python -m doctest -v examples/wiki/wiki.py
25+
uv run sphinx-build -E -b doctest {{sphinx_opts}} {{docs_build}}/doctest
26+
uv run sphinx-build -b linkcheck {{sphinx_opts}} {{docs_build}}/linkcheck
1927

2028
typing:
2129
uv run mypy --install-types --non-interactive .

0 commit comments

Comments
 (0)