-
Notifications
You must be signed in to change notification settings - Fork 1.3k
tests: fix test_exceptions #7326
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
tests: fix test_exceptions #7326
Conversation
5d3b8b9 to
3b7060c
Compare
tests/func/utils/test_strict_yaml.py
Outdated
| for l_expected, l_err in zip(expected.split("\n"), err.split("\n")): | ||
| assert l_expected.rstrip(" ") == l_err.rstrip(" ") |
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.
Let's use splitlines, and not use rstrip() in the expected value. Also rstrip defaults to ascii whitespace.
| for l_expected, l_err in zip(expected.split("\n"), err.split("\n")): | |
| assert l_expected.rstrip(" ") == l_err.rstrip(" ") | |
| for l_expected, l_err in zip(expected.splitlines(), err.splitlines()): | |
| assert l_expected == l_err.rstrip() |
You may however need to fix some examples.
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.
Few nitpicky suggestions:
- I prefer
_linesuffix thanl_prefix. Keep expected value on the right hand side.(That's fine I think).
| for l_expected, l_err in zip(expected.split("\n"), err.split("\n")): | |
| assert l_expected.rstrip(" ") == l_err.rstrip(" ") | |
| for expected_line, err_line in zip(expected.splitlines(), err.splitlines()): | |
| assert expected_line == err_line.rstrip() |
But no strong opinion, just being nitpicky here.
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.
Note that using rstrip() instead of rstrip(" ") will also strip newlines
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.
Note that using rstrip() instead of rstrip(" ") will also strip newlines
@dtrifiro, sorry, you are right. I was confusing it with bytes.rstrip() for some reason.
3b7060c to
3d3f9b9
Compare
tests/func/utils/test_strict_yaml.py
Outdated
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.
| extra keys not allowed, in stages -> stage1 -> outs -> 0 -> logs ->\n\ | |
| extra keys not allowed, in stages -> stage1 -> outs -> 0 -> logs -> |
tests/func/utils/test_strict_yaml.py
Outdated
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.
Does this fit on a single line now?
| Found duplicate key "cmd" with value "python train.py" (original value:\ | |
| Found duplicate key "cmd" with value "python train.py" (original value: "python |
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.
Probably linters will complain though, black does not for some reason, hmm.
tests/func/utils/test_strict_yaml.py
Outdated
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.
Similarly, if python moves above, this could be written as:
| "python\ntrain.py"), in line 4, column 5 | |
| train.py"), in line 4, column 5 |
3d3f9b9 to
d506071
Compare
d506071 to
a7d0aa4
Compare
|
Thank you so much @dtrifiro for the quickfix. 🙂 |
Due to changes in
rich11.1.0, all text formatted usingrich.syntax.Syntaxis now left-justified (see 0a37fcc),resulting in output padded with whitespace to the size of the tty.
This resulted in broken tests due to mismatching whitespace between actual
dvc.uioutput and test cases.Stripping whitespace in the ui output in
test_exceptionssolves the broken tests for bothrich11.1.0and11.0.0fixes #7322