Skip to content

Commit 853ebeb

Browse files
committed
docstrings and type annotations for doctests
1 parent 0ff4697 commit 853ebeb

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

doctests.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,41 @@
22
import os
33
import unittest
44
import sys
5+
from typing import Any
56

67

7-
def load_tests(loader, tests, ignorex):
8+
def load_tests(loader: unittest.TestLoader, tests: unittest.TestSuite, ignorex: Any) -> unittest.TestSuite:
9+
"""Discover and add all reStructuredText (.rst) doctest files within the current directory tree to the test suite.
10+
11+
Parameters
12+
----------
13+
loader : unittest.TestLoader
14+
The test loader instance used to load the tests.
15+
tests : unittest.TestSuite
16+
The existing test suite to which doctest suites will be added.
17+
ignorex : Any
18+
A placeholder parameter (typically unused) required by the unittest framework.
19+
20+
Returns
21+
-------
22+
unittest.TestSuite
23+
The updated test suite including all discovered .rst doctest files.
24+
25+
Notes
26+
-----
27+
This function is used by the unittest framework to discover and include additional doctests
28+
in the test suite during test discovery.
29+
30+
"""
831
for root, dirs, files in os.walk("."):
932
for f in files:
1033
if f.endswith(".rst"):
1134
tests.addTests(
1235
doctest.DocFileSuite(
13-
os.path.join(root, f), optionflags=doctest.ELLIPSIS
36+
os.path.join(root, f),
37+
optionflags=doctest.ELLIPSIS
1438
)
1539
)
16-
1740
return tests
1841

1942

0 commit comments

Comments
 (0)