Uh oh!
There was an error while loading. Please reload this page.
Fix test_exapp - #288
Conversation
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.
| 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.
__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.
#287 (comment) explains why positional argument cli is removed.
| def setUp(self): | ||
| super().setUp() | ||
| self.cli = mycli |
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
Yang Wang (RyoYang)
commented
Aug 21, 2024
Do we have an ETA to merge this PR? Jiashuo Li (@jiasli) |
Fix#287