Skip to content

Commit 5a02032

Browse files
committed
[tests] refactor python tests
* try to adapt a more modern python style * add flake8 linting and mypy type checking * add many type hints * dataclasses * various refactorings to make proper type hints possible * use f-strings for formatting instead of `%` and `.format` * get rid of `Env` global; pass it explicitly or use a ContextVar * use metaclass to automatically register test cases Change-Id: I19d6223157b769cb6491c032d3ec9eb2cd70ef44
1 parent a5e8c80 commit 5a02032

31 files changed

+2851
-2629
lines changed

.flake8

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
# E266 too many leading '#' for block comment [ I like marking disabled code blocks with '### ' ]
3+
# E402 module level import not at top of file [ usually on purpose. might use individual overrides instead? ]
4+
# E713 test for membership should be ‘not in’ [ disagree: want `not a in x` ]
5+
# E714 test for object identity should be 'is not' [ disagree: want `not a is x` ]
6+
# W503 line break before binary operator [ gotta pick one way ]
7+
extend-ignore = E266,E402,E713,E714,W503
8+
max-line-length = 120

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ install-sh
1515
ltmain.sh
1616
missing
1717
CMakeLists.txt.user
18+
.vscode
19+
.mypy_cache

pyproject.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[tool.pyright]
2+
include = ["tests"]
3+
4+
[[tool.pyright.executionEnvironments]]
5+
root = "tests"
6+
7+
[tool.mypy]
8+
warn_unused_configs = true
9+
mypy_path = "tests"
10+
files = "tests"
11+
implicit_reexport = false
12+
show_error_codes = true
13+
follow_imports = "silent"

tests/CONTRIBUTE.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Please run `mypy` and `flake8 tests` in project root and fix errors/lints.

0 commit comments

Comments
 (0)