Skip to content

Commit 304c4c5

Browse files
committed
Run doctests for each package.
1 parent 01e96f3 commit 304c4c5

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

.github/workflows/docs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,3 @@ jobs:
2222
pip install -r requirements/3.10.txt
2323
- name: Build documentation
2424
run: make docs
25-
- name: Run doctests
26-
run: make doctests

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ jobs:
6868
- name: Run tests
6969
if: matrix.component != 'meta'
7070
run: make ${{ matrix.component }}/tests
71+
- name: Run doctests
72+
if: matrix.component != 'meta'
73+
run: make ${{ matrix.component }}/doctest
7174
- name: Build the package
7275
run: make ${{ matrix.component }}/dist
7376
- name: Upload the package to pypi

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ UPLOAD = $(addsuffix /upload,${PACKAGES})
1212
# All */tests folders for each of the test suites.
1313
TESTS = $(addsuffix /tests,$(filter-out meta,${PACKAGES}))
1414
TESTS_DIND = $(addsuffix -dind,${TESTS})
15+
DOCTESTS = $(addsuffix /doctest,$(filter-out meta,${PACKAGES}))
1516
# All linting targets.
1617
LINT = $(addsuffix /lint,${PACKAGES})
1718

@@ -56,9 +57,12 @@ ${TESTS_DIND} : %/tests-dind : image
5657
docs :
5758
sphinx-build -nW . docs/_build
5859

59-
doctests :
60+
doctest : ${DOCTESTS}
6061
sphinx-build -b doctest . docs/_build
6162

63+
${DOCTESTS} : %/doctest :
64+
sphinx-build -b doctest -c doctests $* docs/_build
65+
6266
# Targets to build requirement files
6367
requirements : ${REQUIREMENTS}
6468
${REQUIREMENTS} : requirements/%.txt : requirements.in */setup.py

core/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ testcontainers-core
22
===================
33

44
:code:`testcontainers-core` is a utility package for spinning up Docker containers in testing environments.
5+
6+
.. autoclass:: testcontainers.core.container.DockerContainer

core/testcontainers/core/container.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010

1111

1212
class DockerContainer(object):
13+
"""
14+
Basic container object to spin up Docker instances.
15+
16+
.. doctest::
17+
18+
>>> from testcontainers.core.container import DockerContainer
19+
>>> from testcontainers.core.waiting_utils import wait_for_logs
20+
21+
>>> with DockerContainer("hello-world") as container:
22+
... delay = wait_for_logs(container, "Hello from Docker!")
23+
"""
1324
def __init__(self, image, docker_client_kw: dict = None, **kwargs):
1425
self.env = {}
1526
self.ports = {}

doctests/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extensions = [
2+
"sphinx.ext.autodoc",
3+
"sphinx.ext.doctest",
4+
]
5+
master_doc = "README"

0 commit comments

Comments
 (0)