forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix regex split for subtest names #22107
Merged
eleanorjboyd
merged 2 commits into
microsoft:main
from
eleanorjboyd:subtest-regex-split
Sep 28, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hi @eleanorjboyd and @rzhao271 / @roblourens. I already commented on #21733, but I didn't realize you were parsing the
unittest
output directly and therefore have to deal with whatever extra brackets it is inserting. In that case, this test is correct but also misleading, because you can't dowith self.subTest(value1, value2)
- that will result in a Python TypeError, on 3.10 at least.As per the
subTest
documentation (https://docs.python.org/3/library/unittest.html#unittest.TestCase.subTest), the only choices are to pass a string (msg
) or to pass kwargs (**params
) or to pass both. I just tested now and if you pass both a string and a kwargs, then it will print both the string in square brackets and the kwargs in round brackets, so your current regex may not handle that case.It might be useful to have an end-to-end test for this stuff, i.e. first create some real-world Python unit tests that are run with the targeted versions of Python, then use the output of those as the input for the VS Code parser. This way you can be sure that if the Python default test runner changes its output format in a future version, it won't mysteriously break the VS Code parsing which was expecting something different. Alternatively - and I am not sure how hard this would be to do - VS Code could have its own test runner, which should allow access to the internal data structures that Python
unittest
is using, and then you could create a nice JSON structure to enable all kinds of cool front end features (e.g. filter by individual kwarg).