Mercurial > p > roundup > code
annotate pyproject.toml @ 7822:1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
Pytest 6 is required to use this. This means it works only for python3.
It includes a dummy setting for redis password assuming redis is
running at the default port. This requires pytest-env be installed.
At some point I expect to add project and build-system tables to allow
building using the build package. The version and long_description
specifiers in the project table will be dynamic since the version is
from roundup/__init__.py and description from doc/announcement.txt.
One open issue is how to support the equivalent of:
python setup.py build_doc
to run sphinx over the docs and include them in the share directory
bundled with the distributions.
Modified test_redis_session.py to better handle empty password.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 23 Mar 2024 02:56:01 -0400 |
| parents | |
| children | 9c58f5940c20 |
| rev | line source |
|---|---|
|
7822
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1 [tool.pytest.ini_options] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2 # Note this only works under python3. Pytest 6.0+ supports |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
3 # pyproject.toml and is not available for python 2. These settings can |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
4 # be adapted for pytest.ini if you are running under python2. |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
5 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
6 # For use with packages: |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
7 # python -m pip install pytest-cov pytest-env pytest-randomly |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
8 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
9 minversion = "6.0" |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
10 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
11 # Disable randomly by default. There are still a few tests that are |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
12 # order dependent. Enable on cli for python3 only using: |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
13 # "-p randomly" |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
14 addopts = "-p no:randomly --durations=10 --strict-markers -r a -v" |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
15 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
16 # Set the redis password to nothing. Can be overridden on cli using: |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
17 # "-e pytest_redis_pw=mySecretPassword" |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
18 env = [ |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
19 "D:pytest_redis_pw=" |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
20 ] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
21 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
22 # Don't search random directories to find tests. |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
23 testpaths = [ |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
24 "test", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
25 ] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
26 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
27 [tool.ruff] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
28 line-length = 128 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
29 output-format = "full" |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
30 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
31 exclude = [ |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
32 # ignore code imported/sourced from other places |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
33 "roundup/cgi/PageTemplates/*.py", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
34 "roundup/cgi/TAL/*.py", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
35 "roundup/cgi/ZTUtils/*.py", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
36 "roundup/anypy/vendored/*.py", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
37 "dicttoxml.py" |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
38 ] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
39 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
40 [tool.ruff.lint] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
41 select = [ |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
42 "A", # flake-8-builtins shadowing a builtin |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
43 "ARG", # flake8-unused-arguments |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
44 "B", # flake8-bugbear |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
45 "C4", # flake8-comprehensions |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
46 "C901", # McCabe complexity |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
47 "COM", # flake8-commas |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
48 "E", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
49 "F", # pyflakes |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
50 "G", # logging format _(.... % ...) bad use _(...) % ... |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
51 "I", # imports |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
52 "INT", # check gettext |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
53 "Q", # quoting consistancy |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
54 "PERF", # performance lint |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
55 "PIE794", # duplicate class field definition |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
56 "PL", # pylint |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
57 "RET", # check for inconistent returns |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
58 "RUF", # ruff |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
59 "S", # bandit - security |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
60 "SIM", # simplify code |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
61 "T10", # flake8-debugger |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
62 "W", # pycode whitespace warnings |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
63 ] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
64 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
65 ignore = [ |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
66 # raise from except hander with none or chaining; only python3 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
67 "B904", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
68 # ### before comments is fine |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
69 "E266", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
70 # ignore double vs. single quotes |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
71 "Q000", "Q001", "Q002", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
72 # do not replace x in (a,b) with x in {a,b} (set). python 3.2 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
73 # got a speedup in this; only python 3 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
74 "PLR6201", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
75 # 505: allow use of else/elif even if it could be removed. |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
76 # if X: return; elif Z: return; else v -> |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
77 # if X: return; if Z: return; v |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
78 # 506: same but with a raise rather than return |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
79 #"RET505", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
80 #"RET506", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
81 # use *list to expand; only python 3 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
82 "RUF005", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
83 # do not use contextlib.suppress rather than except: pass to suppress |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
84 # exception. contextlib doesn't work in python2 and is slower |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
85 "SIM105", |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
86 ] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
87 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
88 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
89 [tool.ruff.lint.per-file-ignores] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
90 "roundup/anypy/*.py" = ["RET505", "RET506"] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
91 "roundup/dehtml.py" = ["E501"] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
92 "roundup/rest.py" = ["E501"] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
93 "roundup/support.py" = ["E401"] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
94 "roundup/security.py" = ["E701"] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
95 "roundup/date.py" = ["E231", "E701"] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
96 "roundup/backends/back_sqlite.py" = [ "E203" ] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
97 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
98 [too.ruff.lint.pylint] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
99 max-args = 6 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
100 max-branches=20 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
101 max-statements = 100 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
102 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
103 [tool.ruff.lint.mccabe] |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
104 max-complexity = 50 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
105 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
106 # |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
107 #skip= |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
108 # C901 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
109 # E228 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
110 # E302 |
|
1b7162938988
test: add pyproject.toml: set pytest and ruff project defaults
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
111 # E401 |
