Skip to content

Commit 9e17beb

Browse files
Fix failing test cases
1 parent 522fff9 commit 9e17beb

File tree

5 files changed

+44
-48
lines changed

5 files changed

+44
-48
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ Learn more by reading [the documentation](https://comp1010unsw.github.io/pyhtml-
4646
<h1>
4747
Hello, world!
4848
</h1>
49-
<p>
50-
This is my amazing website!
51-
</p>
49+
<p>This is my amazing website!</p>
5250
</body>
5351
</html>
5452

docs/compatibility.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ modify the original instance, as I found the old behaviour confusing and
2929
bug-prone.
3030

3131
```py
32-
>>> para = p.p("Base paragraph")
33-
>>> para2 = para("Extra text")
34-
>>> para2
35-
<p>
32+
>>> span1 = p.span("Base paragraph")
33+
>>> span2 = span1("Extra text")
34+
>>> span2
35+
<span>
3636
Base paragraph
3737
Extra text
38-
</p>
39-
>>> para
40-
<p>
38+
</span>
39+
>>> span1
40+
<span>
4141
Base paragraph
42-
</p>
42+
</span>
4343

4444
```

docs/index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ Build HTML documents in Python with a simple and learnable syntax.
3232
<h1>
3333
Hello, world!
3434
</h1>
35-
<p>
36-
This is my amazing website!
37-
</p>
35+
<p>This is my amazing website!</p>
3836
</body>
3937
</html>
4038

tests/basic_rendering_test.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
head,
1717
html,
1818
input,
19-
p,
2019
script,
2120
span,
2221
title,
@@ -46,16 +45,16 @@ def test_renders_elements_with_children():
4645
def test_renders_deeply_nested_children():
4746
doc = body(
4847
div(
49-
p("Hello world"),
48+
span("Hello world"),
5049
),
5150
)
5251

5352
assert str(doc) == '\n'.join([
5453
'<body>',
5554
' <div>',
56-
' <p>',
55+
' <span>',
5756
' Hello world',
58-
' </p>',
57+
' </span>',
5958
' </div>',
6059
'</body>',
6160
])
@@ -158,7 +157,7 @@ def test_larger_page():
158157
),
159158
body(
160159
h1("Hello, world!"),
161-
p("This is my amazing website rendered with PyHTML Enhanced!"),
160+
span("This is my amazing website rendered with PyHTML Enhanced!"),
162161
),
163162
)
164163

@@ -176,9 +175,9 @@ def test_larger_page():
176175
' <h1>',
177176
' Hello, world!',
178177
' </h1>',
179-
' <p>',
178+
' <span>',
180179
' This is my amazing website rendered with PyHTML Enhanced!',
181-
' </p>',
180+
' </span>',
182181
' </body>',
183182
'</html>',
184183
])
@@ -196,16 +195,16 @@ def test_flatten_element_lists():
196195
If a list of elements is given as a child element, each element should be
197196
considered as a child.
198197
"""
199-
doc = body([p("Hello"), p("world")])
198+
doc = body([span("Hello"), span("world")])
200199

201200
assert str(doc) == "\n".join([
202201
"<body>",
203-
" <p>",
202+
" <span>",
204203
" Hello",
205-
" </p>",
206-
" <p>",
204+
" </span>",
205+
" <span>",
207206
" world",
208-
" </p>",
207+
" </span>",
209208
"</body>",
210209
])
211210

tests/end_to_end/flask_test.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Tests to ensure our code works nicely with Flask
33
"""
4+
45
import pytest
56
from flask import Flask
67
from flask.testing import FlaskClient
@@ -12,12 +13,14 @@
1213

1314
@app.get("/")
1415
def 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&#x27;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&#x27;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

6970
def 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

Comments
 (0)