-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Assert error message content in tests #37
Conversation
1f166be
to
93ea3f0
Compare
Also, just to flag that one of the commits (ecc12c2) makes a change to the GitHub Actions config. |
93ea3f0
to
9c0f189
Compare
Fixed tests failing on Python 3.7 due to annotation with And also just added:
We'd lost a line of coverage after "test: assert the messages of raised errors" as no test was triggering the "options (case-insensitive) was found in usage" error. I added a test to trigger it, and in doing so realised the code checking for the error condition was not handling options sections with extra qualifying words, like "Advanced Options:". And further to that, a separate error occurred with 3+ word Options sections. |
tests/test_docopt.py
Outdated
docopt("Usage: prog", "-x") | ||
|
||
with raises(DocoptLanguageError): | ||
# -o needs an argument in usage. The "unmatched" error is because `-o` is |
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.
Could you open a separate issue for this? I don't think I totally understand
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.
Sure, I've taken out the message assertion/comment. It's a weird quirk of the way the parser is implemented, not at all intuitive. (Just to avoid any confusion, this isn't something I've changed here, it's just existing behaviour that I was asserting the message of.)
I've fixed the issue in a separate branch I'm working on to improve the usability of the error messages, it can wait for that.
Codecov Report
@@ Coverage Diff @@
## master #37 +/- ##
===========================================
+ Coverage 99.79% 100.00% +0.20%
===========================================
Files 1 1
Lines 487 492 +5
===========================================
+ Hits 486 492 +6
+ Misses 1 0 -1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
51d3d1f
to
c817b29
Compare
Yep, I can rebase this up once 36 is sorted. |
Eh I just tried to fix the merge conflicts in the Web UI and it doesn't look that good, do you think you could actually do a rebase locally and fix the conflicts in their respective commits? |
The .gitignore now ignores all dotfiles at the repo root, other than those explicitly not ignored with !.
Flake8 will spend a long time scanning the virtualenv files dir if the readme instructions are followed, creating one at /.venv.
It's a bit distracting when running tests during development to have coverage printed every time, and slows down the tests somewhat. Coverage and mypy are now run by CI, but not by default with pytest.
It was un-covered in the coverage report.
I need to know that these code paths are hit by tests.
These errors are not triggered by current tests.
This can only occur because of programmer error.
These errors are caused by bad usage docs, they shouldn't ever trigger DocoptExit as they're not the end user's fault.
A lot of docopt tests call docopt() without specifying argv, which uses `sys.argv` by default, so a predictable value for it is necessary.
I'm planning to make the error messages more user-friendly, (especially "Warning: found unmatched (duplicate?) arguments ..."), so I need to verify what the messages currently are so I can ensure that any changes are expected.
85506a9
to
df66068
Compare
@NickCrews No problem, there were quite a few merge conflicts in there! I've rebased it on master. Two of the changes/fixes from here were indirectly fixed by #36 so they're gone now: Should be good to go! |
Excellent work @h4l ! I'm going to add the isort-ing now. Didn't want to add before and cause more merge conflicts. |
Very sensible, thanks @NickCrews! I guess when you do the isort pr it's probably easier to just take the change adding the isort config and re-run it to update the files rather than using the commit I made. |
I'm going to have a crack at making the error messages a little more user-friendly, to resolve #5. Especially the
Warning: found unmatched (duplicate?) arguments [Argument(None, '.\\10. PowerShell.ps1')]
that occurs in response to an end user passing incorrect or too many arguments when running a program using docopt-ng. I need that to be resolved before I can usedocopt-ng
in place of docopt really.Before making changes there, I'd like to ensure the current messages are tested, so I can be sure I don't change messages unexpectedly.
This PR mostly adds exception message assertions to all the places where tests trigger an exception or
SystemExit
with usage.The first 3 commits are unrelated to these messages assertions — small improvements to the dev experience using this repo. They could go into a separate PR if you prefer, but I've already opened a few, so I didn't want to swamp with too many!