Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve unit test runner #419

Open
JelleZijlstra opened this issue Oct 28, 2023 · 3 comments
Open

Improve unit test runner #419

JelleZijlstra opened this issue Oct 28, 2023 · 3 comments

Comments

@JelleZijlstra
Copy link
Collaborator

This project's unit tests are sort of annoying to work with as you have to manually type out line numbers in the test file. This is especially bad if we reformat something and a bunch of line numbers change.

It would be nice to switch to flake8-pyi's setup or a variant (https://github.com/PyCQA/flake8-pyi/blob/main/tests/test_pyi_files.py), which puts the expected errors inline in the test files.

@AlexWaygood
Copy link
Contributor

AlexWaygood commented Oct 28, 2023

It looks like bugbear's tests currently assert the column number an error occurs on, as well as the line number — you won't be able to do that with a flake8-pyi-esque setup.

I don't think that's a huge issue, though. Having also contributed to both projects, I agree that flake8-pyi's test suite is much nicer to work with! This sounds like a great idea.

@cooperlees
Copy link
Collaborator

FWIW - We've at least disabled black on test code so we don't reformat and change numbers as much with formatting changes.

@jakkdl
Copy link
Contributor

jakkdl commented Oct 28, 2024

I've also written a similar thing for flake8-async that handles multiple test codes per file, column number, and parameters: https://github.com/python-trio/flake8-async/blob/424566816d11d6d465df3688f6e3def05e239756/tests/test_flake8_async.py#L366, see e.g. https://github.com/python-trio/flake8-async/blob/main/tests/eval_files/async22x.py

The test runner also supports a ridiculous amount of other QoL stuff I've added to it over time, some of them documented: https://flake8-async.readthedocs.io/en/latest/contributing.html#meta-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants