You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* revamp testing infra
* use pytest
* fix lower python versions
* add instructions to DEVELOPMENT.md, move eval files to tests/eval_files
* remove old commented-out code
* clarified error message
* fix comment (it applied to flake8-async, but this implementation does not allow # error: ...)
Copy file name to clipboardExpand all lines: DEVELOPMENT.md
+28-3Lines changed: 28 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,23 +42,48 @@ cd flake8-bugbear
42
42
/path/to/venv/bin/pip install -e '.[dev]'
43
43
```
44
44
45
+
## Writing Tests
46
+
47
+
flake8-bugbear has a test runner that will go through all files in `tests/eval_files/`, run them through the linter, and check that they emit the appropriate error messages.
48
+
49
+
The expected errors are specified by adding comments on the line where the error is expected. The format consists of the error code, followed by a comma-separated list of the `col_offset` as well as `vars` that are used when `str.format`ing the full error message.
The error code should be in the `error_codes` dict, and the other values are `eval`'d as if in a `tuple` and should be valid python objects. (I.e. remember to quote strings)
58
+
59
+
You can also specify options to be passed to `BugBearChecker` with an `# OPTIONS` comments
If you specify a python version somewhere in the file name with `_pyXX`, the file will be skipped on smaller versions. Otherwise the name has no impact on the test, and you can test multiple errors in the same file.
66
+
67
+
The infrastructure is based on the test runner in https://github.com/python-trio/flake8-async which has some additional features that can be pulled into flake8-bugbear when desired.
68
+
69
+
45
70
## Running Tests
46
71
47
72
flake8-bugbear uses coverage to run standard unittest tests.
48
73
49
74
```console
50
-
/path/to/venv/bin/coverage run tests/test_bugbear.py
75
+
/path/to/venv/bin/coverage run -m pytest tests/test_bugbear.py
51
76
```
52
77
53
78
You can also use [tox](https://tox.wiki/en/latest/index.html) to test with multiple different python versions, emulating what the CI does.
54
79
55
80
```console
56
81
/path/to/venv/bin/tox
57
82
```
58
-
will by default run all tests on python versions 3.8 through 3.12. If you only want to test a specific version you can specify the environment with `-e`
83
+
will by default run all tests on python versions 3.9 through 3.13. If you only want to test a specific version you can specify the environment with `-e`
0 commit comments