Flask Test Client Api
# Flask Test Client API | Online Tutorial
FlaskClient is a simulated browser that can send requests and verify responses without starting a server.
Create an instance via app.test_client().
* * *
## Create Test Client
| Method | Description |
| --- | --- |
| app.test_client(use_cookies=True) | Standard creation. use_cookies=False disables cookie handling |
| with app.test_client() as client: | Context manager. Automatically cleans up request context on exit |
* * *
## Request Methods
All methods return TestResponse object (inherits from Response).
| Method | Description |
| --- | --- |
| get(path, **kwargs) | Send GET request |
| post(path, **kwargs) | Send POST request |
| put(path, **kwargs) | Send PUT request |
| delete(path, **kwargs) | Send DELETE request |
| patch(path, **kwargs) | Send PATCH request |
| open(path, method, **kwargs) | Generic request method, requires explicit method specification |
YouTip