Fixed the long lines in the AuthenticationTestCase and FlaskLoginTestCase test cases.

This commit is contained in:
依瑪貓 2022-11-30 23:35:04 +08:00
parent 0dfdf70c45
commit bbaebbc80d
2 changed files with 6 additions and 8 deletions

View File

@ -63,9 +63,8 @@ class AuthenticationTestCase(TestCase):
auth: DigestAuth = DigestAuth(realm=_REALM)
auth.init_app(app)
user_db: t.Dict[str, User] \
= {_USERNAME: User(
_USERNAME, make_password_hash(_REALM, _USERNAME, _PASSWORD))}
pw_hash: str = make_password_hash(_REALM, _USERNAME, _PASSWORD)
user_db: t.Dict[str, User] = {_USERNAME: User(_USERNAME, pw_hash)}
@auth.register_get_password
def get_password_hash(username: str) -> t.Optional[str]:

View File

@ -86,9 +86,8 @@ class FlaskLoginTestCase(TestCase):
auth: DigestAuth = DigestAuth(realm=_REALM)
auth.init_app(app)
user_db: t.Dict[str, User] \
= {_USERNAME: User(
_USERNAME, make_password_hash(_REALM, _USERNAME, _PASSWORD))}
pw_hash: str = make_password_hash(_REALM, _USERNAME, _PASSWORD)
user_db: t.Dict[str, User] = {_USERNAME: User(_USERNAME, pw_hash)}
@auth.register_get_password
def get_password_hash(username: str) -> t.Optional[str]:
@ -154,7 +153,7 @@ class FlaskLoginTestCase(TestCase):
:return: None.
"""
if not self.has_flask_login:
self.skipTest("Skipped testing Flask-Login integration without it.")
self.skipTest("Skipped without Flask-Login.")
response: Response = self.client.get(self.app.url_for("admin-1"))
self.assertEqual(response.status_code, 401)
@ -175,7 +174,7 @@ class FlaskLoginTestCase(TestCase):
:return: None.
"""
if not self.has_flask_login:
self.skipTest("Skipped testing Flask-Login integration without it.")
self.skipTest("Skipped without Flask-Login.")
admin_uri: str = self.app.url_for("admin-1")
response: Response