11"""
22Tests to ensure our code works nicely with Flask
33"""
4+
45import pytest
56from flask import Flask
67from flask .testing import FlaskClient
1213
1314@app .get ("/" )
1415def simple_route ():
15- return str (p .html (
16- p .body (
17- p .p ("This app is to test Flask's integration with PyHTML." ),
18- p .a (href = "/no_str" )("Click here to get a 500 error." ),
16+ return str (
17+ p .html (
18+ p .body (
19+ p .p ("Testing Flask's integration with PyHTML." ),
20+ p .a (href = "/no_str" )("Click here to get a 500 error." ),
21+ )
1922 )
20- ))
23+ )
2124
2225
2326# This route intentionally returns the wrong type
@@ -27,9 +30,7 @@ def no_stringify():
2730 This route intentionally returns an un-stringified PyHTML object. We use
2831 it to test that a reasonable error message is given
2932 """
30- return p .html (
31- p .body ("Hello, world!" )
32- )
33+ return p .html (p .body ("Hello, world!" ))
3334
3435
3536@pytest .fixture
@@ -51,19 +52,19 @@ def test_simple_stringify(client: FlaskClient):
5152 response = client .get ("/" )
5253 assert response .status_code == 200
5354
54- assert response .text == ' \n ' .join ([
55- '<!DOCTYPE html>' ,
56- '< html>' ,
57- ' <body>' ,
58- ' <p>' ,
59- ' This app is to test Flask's integration with PyHTML.' ,
60- ' </p >' ,
61- ' <a href="/no_str">' ,
62- ' Click here to get a 500 error.' ,
63- ' </a>' ,
64- ' </body>' ,
65- '</html>' ,
66- ] )
55+ assert response .text == " \n " .join (
56+ [
57+ "<!DOCTYPE html>" ,
58+ "<html>" ,
59+ " <body>" ,
60+ " <p>Testing Flask's integration with PyHTML.</p>" ,
61+ ' <a href="/no_str" >' ,
62+ " Click here to get a 500 error." ,
63+ " </a>" ,
64+ " </body>" ,
65+ "</html>" ,
66+ ]
67+ )
6768
6869
6970def test_failed_to_stringify (client : FlaskClient ):
@@ -78,5 +79,5 @@ def test_failed_to_stringify(client: FlaskClient):
7879
7980
8081# Ignore coverage since this won't be used when running tests automatically
81- if __name__ == ' __main__' : # pragma: no cover
82+ if __name__ == " __main__" : # pragma: no cover
8283 app .run (debug = True )
0 commit comments