Removed the test client from thd Sphinx documentation.
This commit is contained in:
		| @@ -199,70 +199,3 @@ In your ``my_app/views.py``: | ||||
| The views only depend on Flask-Login, but not the actual | ||||
| authentication mechanism.  You can change the actual authentication | ||||
| mechanism without changing the views. | ||||
|  | ||||
|  | ||||
| .. _example-unittest: | ||||
|  | ||||
| A unittest Test Case | ||||
| -------------------- | ||||
|  | ||||
| :: | ||||
|  | ||||
|     from flask import Flask | ||||
|     from flask_digest_auth import Client | ||||
|     from flask_testing import TestCase | ||||
|     from my_app import create_app | ||||
|  | ||||
|     class MyTestCase(TestCase): | ||||
|  | ||||
|         def create_app(self): | ||||
|             app: Flask = create_app({ | ||||
|                 "TESTING": True, | ||||
|                 "SECRET_KEY": token_urlsafe(32), | ||||
|                 "DIGEST_AUTH_REALM": "admin", | ||||
|             }) | ||||
|             app.test_client_class = Client | ||||
|             return app | ||||
|  | ||||
|         def test_admin(self): | ||||
|             response = self.client.get("/admin") | ||||
|             self.assertEqual(response.status_code, 401) | ||||
|             response = self.client.get( | ||||
|                 "/admin", digest_auth=(USERNAME, PASSWORD)) | ||||
|             self.assertEqual(response.status_code, 200) | ||||
|  | ||||
|  | ||||
|  | ||||
| .. _example-pytest: | ||||
|  | ||||
| A pytest Test | ||||
| ------------- | ||||
|  | ||||
| :: | ||||
|  | ||||
|     import pytest | ||||
|     from flask import Flask | ||||
|     from flask_digest_auth import Client | ||||
|     from my_app import create_app | ||||
|  | ||||
|     @pytest.fixture() | ||||
|     def app(): | ||||
|         app: Flask = create_app({ | ||||
|             "TESTING": True, | ||||
|             "SECRET_KEY": token_urlsafe(32), | ||||
|             "DIGEST_AUTH_REALM": "admin", | ||||
|         }) | ||||
|         app.test_client_class = Client | ||||
|         yield app | ||||
|  | ||||
|     @pytest.fixture() | ||||
|     def client(app): | ||||
|         return app.test_client() | ||||
|  | ||||
|     def test_admin(app: Flask, client: Client): | ||||
|         with app.app_context(): | ||||
|             response = client.get("/admin") | ||||
|             assert response.status_code == 401 | ||||
|             response = client.get( | ||||
|                 "/admin", digest_auth=(USERNAME, PASSWORD)) | ||||
|             assert response.status_code == 200 | ||||
|   | ||||
| @@ -137,17 +137,6 @@ new username and password. | ||||
| See :meth:`flask_digest_auth.auth.DigestAuth.logout`. | ||||
|  | ||||
|  | ||||
| Test Client | ||||
| ----------- | ||||
|  | ||||
| Flask-DigestAuth comes with a test client that supports HTTP digest | ||||
| authentication. | ||||
|  | ||||
| See :class:`flask_digest_auth.test.Client`. | ||||
|  | ||||
| Also see :ref:`example-unittest` and :ref:`example-pytest`. | ||||
|  | ||||
|  | ||||
| .. _HTTP Digest Authentication: https://en.wikipedia.org/wiki/Digest_access_authentication | ||||
| .. _RFC 2617: https://www.rfc-editor.org/rfc/rfc2617 | ||||
| .. _Flask: https://flask.palletsprojects.com | ||||
|   | ||||
		Reference in New Issue
	
	Block a user