Skip to content

Commit 1d6490b

Browse files
committed
Experiment: Try porting tests to pytest.
1 parent f373b74 commit 1d6490b

24 files changed

+2316
-1981
lines changed

.pre-commit-config.yaml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
4-
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v5.0.0
6-
hooks:
7-
- id: check-added-large-files
8-
- id: check-ast
9-
- id: check-byte-order-marker
10-
- id: check-case-conflict
11-
- id: check-docstring-first
12-
- id: check-merge-conflict
13-
- id: check-toml
14-
- id: check-yaml
15-
- id: debug-statements
16-
- id: end-of-file-fixer
17-
- id: trailing-whitespace
18-
- repo: https://github.com/psf/black
19-
rev: 25.1.0
20-
hooks:
21-
- id: black
22-
language_version: python3.13
23-
name: black (Python formatter)
24-
- repo: https://github.com/pycqa/flake8
25-
rev: 7.2.0
26-
hooks:
27-
- id: flake8
28-
name: flake8 (Python linter)
29-
- repo: https://github.com/econchick/interrogate
30-
rev: 1.7.0
31-
hooks:
32-
- id: interrogate
33-
name: interrogate (Python docstring enforcer)
34-
args: [--quiet]
35-
- repo: https://github.com/pycqa/isort
36-
rev: 6.0.1
37-
hooks:
38-
- id: isort
39-
name: isort (Python formatter)
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-ast
9+
- id: check-byte-order-marker
10+
- id: check-case-conflict
11+
- id: check-docstring-first
12+
- id: check-merge-conflict
13+
- id: check-toml
14+
- id: check-yaml
15+
- id: debug-statements
16+
- id: end-of-file-fixer
17+
- id: trailing-whitespace
18+
- repo: https://github.com/psf/black
19+
rev: 25.1.0
20+
hooks:
21+
- id: black
22+
language_version: python3.13
23+
name: black (Python formatter)
24+
- repo: https://github.com/pycqa/flake8
25+
rev: 7.2.0
26+
hooks:
27+
- id: flake8
28+
name: flake8 (Python linter)
29+
- repo: https://github.com/econchick/interrogate
30+
rev: 1.7.0
31+
hooks:
32+
- id: interrogate
33+
name: interrogate (Python docstring enforcer)
34+
args: [--quiet, --ignore-init-module]
35+
- repo: https://github.com/pycqa/isort
36+
rev: 6.0.1
37+
hooks:
38+
- id: isort
39+
name: isort (Python formatter)

noxfile.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
NOXFILE_PATH / "tests" / "__pycache__",
3737
)
3838

39-
TEST_KEY = "INVALID_TEST_KEY"
40-
TEST_URL = "http://example.com"
39+
TEST_KEY = "invalid-test-key"
40+
TEST_URL = "http://example.com/"
4141

4242

4343
def clean(paths: typing.Iterable[pathlib.Path] = ARTIFACT_PATHS) -> None:
@@ -67,24 +67,26 @@ def tests_with_coverage(session: nox.Session) -> None:
6767
6868
"""
6969
session.install(
70-
".[tests]",
71-
"coverage",
72-
'tomli; python_full_version < "3.11.0a7"',
70+
".",
71+
"anyio",
72+
"pytest",
73+
"coverage[toml]",
7374
)
75+
clean()
7476
session.run(
7577
f"python{session.python}",
76-
"-Wonce::DeprecationWarning",
7778
"-Im",
7879
"coverage",
7980
"run",
8081
"--source",
8182
PACKAGE_NAME,
8283
"-m",
83-
"unittest",
84-
"discover",
84+
"pytest",
85+
"-m",
86+
"not end_to_end",
87+
"-vv",
8588
env={"PYTHON_AKISMET_API_KEY": TEST_KEY, "PYTHON_AKISMET_BLOG_URL": TEST_URL},
8689
)
87-
clean()
8890

8991

9092
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"], tags=["release"])
@@ -95,15 +97,14 @@ def tests_end_to_end(session: nox.Session) -> None:
9597
"""
9698
if IS_CI:
9799
session.skip("Release tests do not run in CI")
98-
session.install(".[tests]")
100+
session.install(".", "anyio", "pytest")
99101
session.run(
100102
f"python{session.python}",
101-
"-Wonce::DeprecationWarning",
102103
"-Im",
103-
"unittest",
104-
"discover",
105-
"--pattern",
106-
"end_to_end*",
104+
"pytest",
105+
"-m",
106+
"end_to_end",
107+
"-vv",
107108
env={
108109
"PYTHON_AKISMET_API_KEY": os.getenv("PYTHON_AKISMET_API_KEY", ""),
109110
"PYTHON_AKISMET_BLOG_URL": os.getenv("PYTHON_AKISMET_BLOG_URL", ""),
@@ -318,7 +319,7 @@ def lint_pylint(session: nox.Session) -> None:
318319
319320
"""
320321
# Pylint requires that all dependencies be importable during the run.
321-
session.install("httpx", "typing-extensions", "pylint")
322+
session.install("httpx", "typing-extensions", "pylint", "pytest")
322323
session.run(f"python{session.python}", "-Im", "pylint", "--version")
323324
session.run(f"python{session.python}", "-Im", "pylint", "src/", "tests/")
324325
clean()

pdm.lock

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

pyproject.toml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ readme = "README.rst"
3737
requires-python = ">=3.9"
3838
version = "24.11.1a0"
3939

40+
[dependency-groups]
41+
tests = [
42+
"anyio",
43+
"coverage[toml]",
44+
"pytest",
45+
]
46+
4047
[project.urls]
4148
"Documentation" = "https://akismet.readthedocs.io"
4249
"Source Code" = "https://github.com/ubernostrum/akismet"
4350

44-
[dependency-groups]
45-
tests = ["nox"]
46-
4751
[tool.bandit]
4852
skips = ["B101", "B113"]
4953

@@ -93,3 +97,21 @@ disable = [
9397
"duplicate-code",
9498
"protected-access",
9599
]
100+
101+
[tool.pytest.ini_options]
102+
filterwarnings = [
103+
"ignore::pytest.PytestCollectionWarning",
104+
]
105+
markers = [
106+
"akismet_async_client",
107+
"akismet_exception_response",
108+
"akismet_fixed_response",
109+
"akismet_sync_client",
110+
"api",
111+
"async_client",
112+
"constructors",
113+
"end_to_end",
114+
"errors",
115+
"sync_client",
116+
"test_client",
117+
]

tests/async_client/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)