Open
Conversation
jiasli
commented
Jul 16, 2024
Member
Author
There was a problem hiding this comment.
The .py file extension is necessary, otherwise pytest won't collect this file at all.
> pytest examples\test_exapp
================================================= test session starts =================================================
platform win32 -- Python 3.11.9, pytest-8.2.2, pluggy-1.5.0
rootdir: D:\cli\knack
plugins: forked-1.6.0, xdist-3.6.1
collected 0 items
================================================ no tests ran in 0.02s ================================================
ERROR: not found: D:\cli\knack\examples\test_exapp
(no match in any of [<Dir examples>])
That's why the error is not exposed in CI.
jiasli
commented
Jul 16, 2024
|
|
||
| def load_command_table(self, args): | ||
| with CommandGroup(self, 'hello', '__main__#{}') as g: | ||
| with CommandGroup(self, 'hello', '{}#{{}}'.format(__name__)) as g: |
Member
Author
There was a problem hiding this comment.
__main__ denotes this file only when this file is directly invoked by python.
When invoked from pytest, __main__ is actually D:\cli\py311\Scripts\pytest.exe\__main__.py. This can be verified by adding import __main__; print(__main__):
> pytest examples\test_exapp.py -s
================================================= test session starts =================================================
platform win32 -- Python 3.11.9, pytest-8.2.2, pluggy-1.5.0
rootdir: D:\cli\knack
plugins: forked-1.6.0, xdist-3.6.1
collecting ... <module '__main__' from 'D:\\cli\\py311\\Scripts\\pytest.exe\\__main__.py'>
jiasli
commented
Jul 16, 2024
Comment on lines
+84
to
+85
| def __init__(self, method_name, filter_headers=None): | ||
| super().__init__(method_name) |
Member
Author
There was a problem hiding this comment.
#287 (comment) explains why positional argument cli is removed.
jiasli
commented
Jul 16, 2024
Comment on lines
+64
to
+66
| def setUp(self): | ||
| super().setUp() | ||
| self.cli = mycli |
Member
Author
There was a problem hiding this comment.
Initializing self.cli in setUp adheres to the "do heavy work in setUp" principle: Azure/azure-cli#28849
|
Do we have an ETA to merge this PR? @jiasli |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix #287