Skip to content

Commit 7d71f72

Browse files
committed
start adding tests
1 parent d688ebf commit 7d71f72

File tree

7 files changed

+187
-4
lines changed

7 files changed

+187
-4
lines changed

.coverage

52 KB
Binary file not shown.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.coverage
12
/.env
23
/output/
34
dist

justfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
black *args="":
2-
uv run black --check src {{ args }}
2+
uv run black --check src tests {{ args }}
33

44
ruff *args="":
55
uv run ruff check {{ args }}
@@ -14,8 +14,8 @@ check: black ruff type-check
1414
{{ just_executable() }} toml-sort --check
1515

1616
fix:
17-
uv run black src
18-
uv run ruff check --fix src
17+
uv run black src tests
18+
uv run ruff check --fix src tests
1919
{{ just_executable() }} toml-sort --in-place
2020

2121
release:
@@ -30,3 +30,9 @@ run *args="":
3030

3131
@html:
3232
just run django.views.generic.FormView --renderer html --output output
33+
34+
35+
test *args="":
36+
uv run -m coverage run --module pytest tests {{ args }}
37+
-uv run -m coverage report
38+
uv run -m coverage html

pyproject.toml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,44 @@ Changelog = "https://github.com/ghickman/classify/blob/main/CHANGELOG.md"
3838
[dependency-groups]
3939
dev = [
4040
"black>=25.9.0,<26",
41+
"coverage>=7.11.0",
4142
"django>=5.2.7",
4243
"ipdb>=0.13.13",
4344
"nox>=2025.10.16",
4445
"nox-uv>=0.6.3",
46+
"pytest>=8.4.2",
4547
"ruff>=0.14.2",
4648
"toml-sort>=0.24.3",
4749
"ty>=0.0.1a24",
4850
]
4951

52+
[tool.coverage.html]
53+
show_contexts = true
54+
55+
[tool.coverage.report]
56+
# fail_under = 100
57+
show_missing = true
58+
skip_covered = true
59+
60+
[tool.coverage.run]
61+
branch = true
62+
relative_files = true
63+
dynamic_context = "test_function"
64+
omit = [
65+
"src/classify/contrib/*",
66+
]
67+
source = ["src", "tests"]
68+
69+
[tool.pytest.ini_options]
70+
addopts = "--tb=native"
71+
5072
[tool.ruff]
5173
line-length = 88
5274
extend-exclude = [
5375
"src/classify/contrib/django/",
5476
"src/classify/templates",
5577
]
56-
src = ["src"]
78+
src = ["src", "tests"]
5779

5880
[tool.ruff.lint]
5981
select = ["ALL"]

tests/__init__.py

Whitespace-only changes.

tests/test_library.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import pytest
2+
3+
from classify.library import get_members
4+
5+
6+
class DummyParent:
7+
def one(self):
8+
print("one parent")
9+
10+
def three(self):
11+
pass
12+
13+
14+
class DummyClass(DummyParent):
15+
def __init__(self):
16+
super().__init__()
17+
18+
def _internal(self):
19+
pass
20+
21+
def one(self):
22+
super().one()
23+
print("one child")
24+
25+
def two(self):
26+
pass
27+
28+
29+
@pytest.mark.parametrize(
30+
("cls", "expected"),
31+
[
32+
(DummyParent, ["__dict__", "__weakref__", "one", "three"]),
33+
(DummyClass, ["__init__", "one", "two"]),
34+
],
35+
ids=["parent", "child"],
36+
)
37+
def test_get_members(cls, expected):
38+
members = get_members(cls)
39+
40+
names = [m[0] for m in members]
41+
42+
assert names == expected, names

uv.lock

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)