-
Notifications
You must be signed in to change notification settings - Fork 314
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
Switch to pytest asserts #1276
Switch to pytest asserts #1276
Conversation
They're easier to read and produce better error messages. This was done mostly automatically with the `self_assert` unittest2pytest fix. (I had to modify unittest2pytest to use fissix instead of lib2to3 as the latter choked on various files.) I also had to change many lines from `assert 0 == value` to `assert value == 0` to please pytest. This isn't a useful pattern in Python because `assert 0 = value` is a syntax error anyway.
@elasticmachine test this please |
This kind of large transformation is much easier to do once automatic code formatting is in place, have you considered switching to black? I also need to change the I can also do this file by file or assert type by assert type to make this easier to review in small chunks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR! IMHO the general direction makes sense.
I have triggered CI and as you suspected there are indeed there are a couple of linter issues at the moment:
************* Module tests.utils.opts_test
tests/utils/opts_test.py:37:0: C0301: Line too long (145/140) (line-too-long)
************* Module tests.mechanic.mechanic_test
tests/mechanic/mechanic_test.py:57:0: C0301: Line too long (150/140) (line-too-long)
************* Module tests.mechanic.team_test
tests/mechanic/team_test.py:155:0: C0301: Line too long (203/140) (line-too-long)
tests/utils/opts_test.py:37:0: C0301: Line too long (145/140) (line-too-long)
tests/mechanic/team_test.py:155:0: C0301: Line too long (203/140) (line-too-long)
************* Module tests.config_test
tests/config_test.py:293:0: C0301: Line too long (141/140) (line-too-long)
************* Module tests.track.params_test
tests/track/params_test.py:138:0: C0301: Line too long (153/140) (line-too-long)
tests/track/params_test.py:141:0: C0301: Line too long (143/140) (line-too-long)
tests/track/params_test.py:797:0: C0301: Line too long (143/140) (line-too-long)
tests/track/params_test.py:1373:0: C0301: Line too long (149/140) (line-too-long)
tests/track/params_test.py:1797:0: C0301: Line too long (142/140) (line-too-long)
tests/mechanic/mechanic_test.py:57:0: C0301: Line too long (150/140) (line-too-long)
************* Module tests.mechanic.supplier_test
tests/mechanic/supplier_test.py:34:0: C0301: Line too long (142/140) (line-too-long)
tests/mechanic/supplier_test.py:37:0: C0301: Line too long (207/140) (line-too-long)
tests/mechanic/supplier_test.py:177:0: C0301: Line too long (151/140) (line-too-long)
tests/mechanic/supplier_test.py:183:0: C0301: Line too long (151/140) (line-too-long)
tests/mechanic/supplier_test.py:542:0: C0301: Line too long (166/140) (line-too-long)
tests/mechanic/supplier_test.py:555:0: C0301: Line too long (164/140) (line-too-long)
************* Module tests.telemetry_test
tests/telemetry_test.py:291:0: C0301: Line too long (157/140) (line-too-long)
tests/telemetry_test.py:304:0: C0301: Line too long (150/140) (line-too-long)
tests/telemetry_test.py:1875:0: C0301: Line too long (158/140) (line-too-long)
tests/telemetry_test.py:2531:0: C0301: Line too long (163/140) (line-too-long)
tests/telemetry_test.py:2544:0: C0301: Line too long (159/140) (line-too-long)
************* Module tests.metrics_test
tests/metrics_test.py:190:0: C0301: Line too long (150/140) (line-too-long)
tests/metrics_test.py:201:0: C0301: Line too long (152/140) (line-too-long)
tests/metrics_test.py:213:0: C0301: Line too long (149/140) (line-too-long)
tests/metrics_test.py:226:0: C0301: Line too long (151/140) (line-too-long)
************* Module tests.track.loader_test
tests/track/loader_test.py:240:0: C0301: Line too long (150/140) (line-too-long)
tests/track/loader_test.py:1759:0: C0301: Line too long (144/140) (line-too-long)
tests/track/loader_test.py:1848:0: C0301: Line too long (145/140) (line-too-long)
tests/track/loader_test.py:1882:0: C0301: Line too long (146/140) (line-too-long)
tests/track/loader_test.py:1936:0: C0301: Line too long (149/140) (line-too-long)
tests/track/loader_test.py:1966:0: C0301: Line too long (153/140) (line-too-long)
tests/track/loader_test.py:2969:0: C0301: Line too long (153/140) (line-too-long)
tests/track/loader_test.py:3005:0: C0301: Line too long (149/140) (line-too-long)
tests/track/loader_test.py:3519:0: C0301: Line too long (152/140) (line-too-long)
tests/track/loader_test.py:3557:0: C0301: Line too long (151/140) (line-too-long)
************* Module tests.driver.runner_test
tests/driver/runner_test.py:192:0: C0301: Line too long (155/140) (line-too-long)
tests/driver/runner_test.py:2177:0: C0301: Line too long (151/140) (line-too-long)
tests/driver/runner_test.py:2193:0: C0301: Line too long (149/140) (line-too-long)
tests/driver/runner_test.py:2456:0: C0301: Line too long (154/140) (line-too-long)
tests/driver/runner_test.py:2673:0: C0301: Line too long (152/140) (line-too-long)
tests/driver/runner_test.py:2751:0: C0301: Line too long (152/140) (line-too-long)
tests/driver/runner_test.py:2796:0: C0301: Line too long (156/140) (line-too-long)
tests/driver/runner_test.py:2874:0: C0301: Line too long (156/140) (line-too-long)
tests/driver/runner_test.py:2920:0: C0301: Line too long (157/140) (line-too-long)
tests/driver/runner_test.py:2999:0: C0301: Line too long (157/140) (line-too-long)
You can also see them locally when running make lint
.
black is on our radar but I fear that we won't have much capacity at the moment to work on it.
That's great. :)
Given the mostly mechanical nature, it's ok for me to do it all at once. The changes themselves should be quick to review even if it spans this many files. |
Thanks, I'll fix the line-too-long lint issues. (I've ran pylint, but am not familiar with the output yet, and don't understand when it fails or does not fail.)
Is it just about the work to set it up, or are there other concerns? |
Closing as I haven't been able to give this pull request the attention it needs, sorry! And it's going to be restarted from scratch anyway. |
They're easier to read and produce better error messages. This was done mostly automatically with the
self_assert
unittest2pytest fix. (I had to modify unittest2pytest to use fissix instead of lib2to3 as the latter choked on various files.)I also had to change many lines from
assert 0 == value
toassert value == 0
to please pytest. This isn't a useful pattern in Python becauseassert 0 = value
is a syntax error anyway.I may have some pylint issues left to fix, but wanted to hear about the general idea first.