You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notice that we are type hinting the test_get_books function.
Because of this (and the fact that this test function lies in another file), pytest attempts to collect tests from TestClient (as the class name starts with "Test").
error traceback:
(server) PS C:\Users\iyapp\OneDrive\Desktop\web-projects\library\server> pytest tests
================================================================================================================================================ test session starts ================================================================================================================================================
platform win32 -- Python 3.10.2, pytest-7.2.2, pluggy-1.0.0
rootdir: C:\Users\iyapp\OneDrive\Desktop\web-projects\library\server
collected 1 item
tests\books\test_routes.py . [100%]
================================================================================================================================================= warnings summary ==================================================================================================================================================
..\..\..\..\..\.virtualenvs\server-vNBXVCHh\lib\site-packages\falcon\testing\client.py:1898
C:\Users\iyapp\.virtualenvs\server-vNBXVCHh\lib\site-packages\falcon\testing\client.py:1898: PytestCollectionWarning: cannot collect test class 'TestClient' because it has a __init__ constructor (from: tests/books/test_routes.py)
class TestClient:
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
This is a known issue, and can be fixed by setting:
Let us consider we have a test case like the following:
Notice that we are type hinting the
test_get_books
function.Because of this (and the fact that this test function lies in another file), pytest attempts to collect tests from TestClient (as the class name starts with "Test").
error traceback:
This is a known issue, and can be fixed by setting:
This is being done already by other frameworks such as starlette:
https://github.com/encode/starlette/blob/master/starlette/testclient.py#L363
I think that the TestClient class must be updated to provide similar behavior.
The text was updated successfully, but these errors were encountered: