Skip to content

Commit f5a33b8

Browse files
committed
run tests with coverage
1 parent 6b95259 commit f5a33b8

File tree

3 files changed

+72
-66
lines changed

3 files changed

+72
-66
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ repos:
3838
hooks:
3939
- id: canonicalize-pyproject
4040
name: Ensure pyproject.toml in canonical order and format
41-
entry: uvx toml-sort --in-place pyproject.toml
41+
entry: uvx toml-sort --in-place --all pyproject.toml
4242
language: system
4343
files: ^pyproject.toml$

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ cqa: ## Run code quality assessments.
5757
.PHONY: test
5858
test: ## Test the code with pytest
5959
@echo "🚀 Testing code: Running pytest"
60-
uv run pytest
60+
uv run pytest --cov=. --cov-report=xml
6161

6262
############################################################################
6363
#= DOCUMENTATION
@@ -83,7 +83,7 @@ clean: ## Remove temporary and backup files
8383
.PHONY: cleaner
8484
cleaner: clean ## Remove files and directories that are easily rebuilt
8585
$(call INFO_MESSAGE, "Remove files and directories that are easily rebuilt")
86-
rm -frv .cache .DS_Store .pytest_cache build coverage.xml dist docs/_build site
86+
rm -frv .cache .DS_Store .pytest_cache .ruff_cache build coverage.xml dist docs/_build site
8787
rm -frv **/*.pyc **/__pycache__ **/*.egg-info
8888
rm -frv **/*.orig **/*.rej
8989

pyproject.toml

Lines changed: 69 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["setuptools >= 70.1", "setuptools_scm[toml] ~= 8.1"]
32
build-backend = "setuptools.build_meta"
3+
requires = ["setuptools >= 70.1", "setuptools_scm[toml] ~= 8.1"]
44

55
[dependency-groups]
66
dev = [
@@ -17,23 +17,25 @@ dev = [
1717
]
1818

1919
[project]
20-
name = "biocommons-example"
2120
authors = [
22-
{name = "biocommons contributors", email = "biocommons[email protected]"}
21+
{email = "biocommons[email protected]", name = "biocommons contributors"}
2322
]
24-
dependencies = ["coloredlogs ~= 15.0", "pyyaml ~= 6.0"]
25-
description = "biocommons.example package (namespaced)"
26-
readme = "README.md"
27-
license = "Apache-2.0"
28-
requires-python = ">=3.10"
2923
classifiers = [
24+
"Intended Audience :: Developers",
3025
"Programming Language :: Python :: 3",
31-
"Programming Language :: Python :: 3.10",
3226
"Programming Language :: Python :: 3.11",
3327
"Programming Language :: Python :: 3.12",
34-
"Operating System :: OS Independent"
28+
"Programming Language :: Python :: 3.13",
29+
"Programming Language :: Python",
30+
"Topic :: Software Development :: Libraries :: Python Modules"
3531
]
32+
dependencies = ["coloredlogs ~= 15.0", "pyyaml ~= 6.0"]
33+
description = "biocommons.example package (namespaced)"
3634
dynamic = ["version"]
35+
license = "Apache-2.0"
36+
name = "biocommons-example"
37+
readme = "README.md"
38+
requires-python = ">=3.10"
3739

3840
[project.optional-dependencies]
3941
example = [
@@ -44,32 +46,32 @@ example = [
4446
marvin-quote = "biocommons.example.__main__:main"
4547

4648
[project.urls]
49+
Documentation = "https://biocommons.github.io/python-package/"
4750
Homepage = "https://biocommons.github.io/python-package/"
4851
Issues = "https://github.com/biocommons/python-package/issues"
4952
Repository = "https://github.com/biocommons/python-package"
50-
Documentation = "https://biocommons.github.io/python-package/"
5153

5254
[tool.coverage]
5355

5456
[tool.coverage.report]
55-
show_missing = true
56-
skip_empty = true
5757
exclude_lines = [
58-
# Have to re-enable the standard pragma
59-
"pragma: no cover",
6058
# Don't complain about missing debug-only code:
6159
"def __repr__",
60+
# Don't complain if non-runnable code isn't run:
61+
"if __name__ == .__main__.:",
6262
"if self.debug",
63+
# Have to re-enable the standard pragma
64+
"pragma: no cover",
6365
# Don't complain if tests don't hit defensive assertion code:
6466
"raise AssertionError",
65-
"raise NotImplementedError",
66-
# Don't complain if non-runnable code isn't run:
67-
"if __name__ == .__main__.:"
67+
"raise NotImplementedError"
6868
]
69+
show_missing = true
70+
skip_empty = true
6971

7072
[tool.coverage.run]
7173
branch = true
72-
omit = ["*_test.py", "*/test/*", "*/tests/*"]
74+
omit = ["*/test/*", "*/tests/*", "*_test.py"]
7375
source = ["src"]
7476

7577
[tool.deptry]
@@ -104,70 +106,74 @@ markers = [
104106
"network: tests that require network connectivity",
105107
"slow: slow tests that should be run infrequently"
106108
]
109+
testpaths = ["tests"]
107110

108111
[tool.ruff]
109-
src = ["src", "tests"]
112+
fix = true
110113
line-length = 100
114+
src = ["src", "tests"]
115+
target-version = "py39"
111116

112117
[tool.ruff.format]
113-
quote-style = "double"
114118
docstring-code-format = true
119+
preview = true
120+
quote-style = "double"
115121

116122
[tool.ruff.lint]
117-
select = [
118-
"F", # https://docs.astral.sh/ruff/rules/#pyflakes-f
119-
"E",
120-
"W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
121-
"I", # https://docs.astral.sh/ruff/rules/#isort-i
122-
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n
123-
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
124-
"YTT", # https://docs.astral.sh/ruff/rules/#flake8-2020-ytt
125-
"S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s
126-
"B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
127-
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
128-
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
129-
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
130-
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
131-
"LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log
132-
"G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
133-
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
134-
"PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
135-
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
136-
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
137-
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
138-
"ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
139-
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
140-
"PL", # https://docs.astral.sh/ruff/rules/#pylint-pl
141-
"TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try
142-
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
143-
"RUF" # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
144-
]
145123
fixable = [
146-
"F401",
147-
"F541",
148-
"I",
149-
"D",
150-
"UP",
151124
"B",
152125
"C4",
126+
"D",
153127
"EM",
128+
"F401",
129+
"F541",
130+
"I",
131+
"PERF",
154132
"PIE",
155133
"PT",
156-
"RSE",
157134
"RET",
135+
"RSE",
136+
"RUF",
158137
"SIM",
159-
"PERF",
160-
"RUF"
138+
"UP"
161139
]
162140
ignore = [
163-
# ignore for compatibility with formatter
164-
"W191",
165141
"E111",
166142
"E114",
167143
"E117",
144+
"E501",
145+
"E731",
146+
"PLR0913",
168147
"S321",
169-
# other
170-
"PLR0913"
148+
"W191"
149+
]
150+
select = [
151+
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
152+
"ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
153+
"B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
154+
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
155+
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
156+
"E",
157+
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
158+
"F", # https://docs.astral.sh/ruff/rules/#pyflakes-f
159+
"G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
160+
"I", # https://docs.astral.sh/ruff/rules/#isort-i
161+
"LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log
162+
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n
163+
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
164+
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
165+
"PL", # https://docs.astral.sh/ruff/rules/#pylint-pl
166+
"PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
167+
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
168+
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
169+
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
170+
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
171+
"S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s
172+
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
173+
"TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try
174+
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
175+
"W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
176+
"YTT" # https://docs.astral.sh/ruff/rules/#flake8-2020-ytt
171177
]
172178

173179
[tool.ruff.lint.per-file-ignores]
@@ -180,8 +186,8 @@ include-package-data = true
180186
"*" = ["*.gz", "*.json", "*.yaml"]
181187

182188
[tool.setuptools.packages.find]
183-
where = ["src"]
184-
exclude = ["__pycache__", "*.pyc"]
189+
exclude = ["*.pyc", "__pycache__"]
185190
namespaces = true
191+
where = ["src"]
186192

187193
[tool.setuptools_scm]

0 commit comments

Comments
 (0)