-
Notifications
You must be signed in to change notification settings - Fork 97
Fix test_exapp #288
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
base: dev
Are you sure you want to change the base?
Fix test_exapp #288
Conversation
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.
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.
|
|
||
| def load_command_table(self, args): | ||
| with CommandGroup(self, 'hello', '__main__#{}') as g: | ||
| with CommandGroup(self, 'hello', '{}#{{}}'.format(__name__)) as g: |
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.
__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'>
| def __init__(self, method_name, filter_headers=None): | ||
| super().__init__(method_name) |
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.
#287 (comment) explains why positional argument cli is removed.
| def setUp(self): | ||
| super().setUp() | ||
| self.cli = mycli |
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.
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 |
Fix #287