Added the test client instruction to README.rst.

This commit is contained in:
依瑪貓 2022-11-24 07:31:46 +11:00
parent a7e2f3296f
commit 5e5d929676

View File

@ -187,6 +187,34 @@ protected Flask module without specifying the authentication
mechanism.
Writing Tests
=============
A test client that handles HTTP Digest Authentication is included.
Example for a unittest testcase:
::
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({
"SECRET_KEY": token_urlsafe(32),
"TESTING": True
})
app.test_client_class = Client
return app
def test_admin(self):
response = self.client.get(
"/admin", digest_auth=("my_name", "my_pass"))
self.assertEqual(response.status_code, 200)
Copyright
=========