Skip to content

Commit

Permalink
Use DocFileSuite to test the readme's example (#77)
Browse files Browse the repository at this point in the history
* Use DocFileSuite to test the readme's example

* Add type annotations

---------

Co-authored-by: Amethyst Reese <amethyst@n7.gg>
  • Loading branch information
thatch and amyreese authored Jan 28, 2024
1 parent d834c2b commit d5ad467
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
1 change: 0 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ lint:
test:
python -m coverage run -m $(SRCS).tests
python -m coverage report
python -m doctest README.md

html: .venv README.md docs/*.rst docs/conf.py
source .venv/bin/activate && sphinx-build -b html docs html
Expand Down
16 changes: 6 additions & 10 deletions stdlibs/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright 2022 Amethyst Reese
# Licensed under the MIT license

import doctest
import os
import sys
from pathlib import Path
from unittest import mock, skipIf, TestCase
from unittest import mock, skipIf, TestCase, TestLoader, TestSuite

import stdlibs

Expand Down Expand Up @@ -51,12 +52,7 @@ def test_all23(self) -> None:
stdlibs.stdlib_module_names("all"),
)

def test_readme_example(self) -> None:
self.assertEqual(
["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"],
[
v
for v in stdlibs.KNOWN_VERSIONS
if "dataclasses" in stdlibs.stdlib_module_names(v)
],
)

def load_tests(loader: TestLoader, tests: TestSuite, _pattern: None) -> TestSuite:
tests.addTests(doctest.DocFileSuite("../../README.md"))
return tests

0 comments on commit d5ad467

Please sign in to comment.