Skip to content

Commit

Permalink
Use pyproject.toml for pytest configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed Dec 11, 2024
1 parent d31bc52 commit 7269d75
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 102 deletions.
86 changes: 56 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,10 @@
# [tool.black]
# line-length = 88
# target-version = ['py38', 'py39', 'py310', 'py311']
# include = '\.pyi?$'
# exclude = '''
# /(
# \.git
# | \.hg
# | \.tox
# | \.venv
# | \.eggs
# | \.cache
# | build
# | __pycache__
# | dist
# | \.*

# )/
# '''

# [tool.isort]
# # See https://black.readthedocs.io/en/stable/compatible_configs.html
# profile = "black"
# src_paths = ["wsgidav", "tests"]


[tool.ruff]
# Decrease the maximum line length to 79 characters.
# line-length = 79
# Support Python 3.10+.
target-version = "py38"
src = ["wsgidav", "tests"]

[tool.ruff.lint.isort]
known-first-party = ["wsgidav", "tests"]

[tool.ruff.lint]
select = [
Expand All @@ -47,6 +19,7 @@ select = [
# "C", # codespell
# "SIM", #
]

ignore = [
# We need the old syntax for python <= 3.9
"UP006", # Use `list` instead of `List` for type annotations (since Py39)
Expand All @@ -61,11 +34,64 @@ ignore = [
"UP031", # Use format specifiers instead of percent format
]

# [tool.ruff.pydocstyle]
# convention = "google"
[tool.ruff.lint.isort]
known-first-party = ["wsgidav", "tests"]


[tool.codespell]
skip = '.git,*.pdf,*.svg,*.lock,*.css,logs'
check-hidden = true
# ignore-regex = ''
# ignore-words-list = ''


# --- Pytest and Coverage Settings ---------------------------------------------
[tool.pytest.ini_options]
# addopts = "-ra -q --cov=wsgidav"

testpaths = [
# ".",
"tests/*.py"
]

markers = [
"benchmarks: include slow benchmarks (enable with '-m benchmarks')",
# "slow: marks tests as slow (deselect with '-m \"not slow\"')",
# "serial",
]

[tool.coverage.run]
# branch = true
omit = [
"tests/*",
"setup.py",
"wsgidav/prop_man/couch_property_manager.py",
"wsgidav/prop_man/mongo_property_manager.py",
"wsgidav/samples/*",
"wsgidav/server/run_reloading_server.py",
"wsgidav/server/server_sample.py",
]

[tool.coverage.report]
precision = 2
# show_missing = true
sort = "Name"
exclude_lines = [
"pragma: no cover",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]

exclude_also = [
# 1. Exclude an except clause of a specific form:
# "except ValueError:\\n\\s*assume\\(False\\)",
# 2. Comments to turn coverage on and off:
# "no cover: start(?s:.)*?no cover: stop",
# 3. A pragma comment that excludes an entire file:
# "\\A(?s:.*# pragma: exclude file.*)\\Z",
"\\A(?s:.*# pragma: exclude-file-from-coverage.*)\\Z",
]

[tool.coverage.html]
directory = "build/coverage"
35 changes: 1 addition & 34 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -98,40 +98,7 @@ ignore =
docs/sphinx-build
docs/sphinx-build/*


[aliases]
# TODO: this breaks 'setup.py test' which is ought to run the Tox-command:
#test = pytest

# isort is configured in pyproject.toml: [tool.isort]
# [isort]

# --- Coverage Settings --------------------------------------------------------

[coverage:run]
branch = True
omit =
tests/*
wsgidav/prop_man/couch_property_manager.py
wsgidav/prop_man/mongo_property_manager.py
wsgidav/samples/*
wsgidav/server/run_reloading_server.py
wsgidav/server/server_sample.py

[coverage:report]
precision = 2
; show_missing = True
sort = Name
exclude_lines =
pragma: no cover
if __name__ == .__main__.:

[coverage:html]
directory = build/coverage

# --- PyTest Settings ----------------------------------------------------------

[tool:pytest]
addopts =
testpaths =
.
tests
52 changes: 14 additions & 38 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ commands =
# https://github.com/pytest-dev/pytest-html/issues/336#issuecomment-1546864331
coverage html --directory=build --ignore-errors
; coverage xml
coverage report --fail-under=30.0 --skip-empty --ignore-errors
coverage report --fail-under=40.0 --skip-empty --ignore-errors


[testenv:mypy]
Expand All @@ -90,6 +90,7 @@ changedir = {toxinidir}
commands =
mypy wsgidav tests


[testenv:lint]
skip_install = true
deps =
Expand All @@ -99,19 +100,6 @@ commands =
ruff check wsgidav tests setup.py
ruff format --check wsgidav tests setup.py

; [testenv:check]
; description = Check Black formatting compliance and add flake8-bugbear checks
; skip_install = true
; deps =
; black ~=24.3
; isort
; {[testenv:lint]deps}
; changedir = {toxinidir}
; commands =
; {[testenv:lint]commands}
; isort --check-only --profile black wsgidav tests setup.py
; black --check --diff wsgidav tests setup.py


[testenv:format]
description = Reformat python code using ruff (Black, isort, and pyupgrade)
Expand All @@ -124,18 +112,18 @@ commands =
{[testenv:lint]commands}


[testenv:upgrade]
description = Upgrade Python syntax to least supported version
deps =
{[testenv:format]deps}
pyupgrade
allowlist_externals:
bash
changedir = {toxinidir}
commands =
# Needs bash-style file pattern expansion:
bash -ec 'pyupgrade --py37-plus --exit-zero-even-if-changed wsgidav/*.py tests/*.py setup.py'
{[testenv:format]commands}
; [testenv:upgrade]
; description = Upgrade Python syntax to least supported version
; deps =
; {[testenv:format]deps}
; pyupgrade
; allowlist_externals:
; bash
; changedir = {toxinidir}
; commands =
; # Needs bash-style file pattern expansion:
; bash -ec 'pyupgrade --py37-plus --exit-zero-even-if-changed wsgidav/*.py tests/*.py setup.py'
; {[testenv:format]commands}


[testenv:docs]
Expand Down Expand Up @@ -175,15 +163,3 @@ deps =
commands =
# http://www.sphinx-doc.org/en/master/man/sphinx-build.html
python setup_bdist_msi.py bdist_msi


# [testenv:clean]
# commands =
# coverage erase


# [testenv:stats]
# commands =
# coverage combine
# coverage report
# coverage html

0 comments on commit 7269d75

Please sign in to comment.