Skip to content

Commit 73213a7

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b016fbd commit 73213a7

File tree

3 files changed

+22
-44
lines changed

3 files changed

+22
-44
lines changed

src/pytest_flask/_internal.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from pytest import Config as _PytestConfig
77

8-
98
_PytestScopeName = Literal["session", "package", "module", "class", "function"]
109

1110

src/pytest_flask/plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env python
22
"""
3-
A py.test plugin which helps testing Flask applications.
3+
A py.test plugin which helps testing Flask applications.
44
5-
:copyright: (c) by Vital Kudzelka
6-
:license: MIT
5+
:copyright: (c) by Vital Kudzelka
6+
:license: MIT
77
"""
8+
89
from typing import Any
910
from typing import List
1011
from typing import Protocol
@@ -25,7 +26,6 @@
2526
from .fixtures import live_server
2627
from .pytest_compat import getfixturevalue
2728

28-
2929
_Response = TypeVar("_Response")
3030

3131

tests/test_live_server.py

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44
from flask import url_for
55

6-
76
pytestmark = pytest.mark.skipif(not hasattr(os, "fork"), reason="needs fork")
87

98

@@ -35,44 +34,38 @@ def test_set_application_server_name(self, live_server):
3534
)
3635

3736
def test_rewrite_application_server_name(self, appdir):
38-
appdir.create_test_module(
39-
"""
37+
appdir.create_test_module("""
4038
import pytest
4139
@pytest.mark.options(server_name='example.com:5000')
4240
def test_a(live_server):
4341
assert live_server.app.config['SERVER_NAME'] == \\
4442
'example.com:%d' % live_server.port
45-
"""
46-
)
43+
""")
4744

4845
result = appdir.runpytest("-v", "-o", "live_server_scope=function")
4946
result.stdout.fnmatch_lines(["*PASSED*"])
5047
assert result.ret == 0
5148

5249
def test_prevent_starting_live_server(self, appdir):
53-
appdir.create_test_module(
54-
"""
50+
appdir.create_test_module("""
5551
import pytest
5652
5753
def test_a(live_server):
5854
assert live_server._process is None
59-
"""
60-
)
55+
""")
6156

6257
result = appdir.runpytest("-v", "--no-start-live-server")
6358
result.stdout.fnmatch_lines(["*passed*"])
6459
assert result.ret == 0
6560

6661
def test_start_live_server(self, appdir):
67-
appdir.create_test_module(
68-
"""
62+
appdir.create_test_module("""
6963
import pytest
7064
7165
def test_a(live_server):
7266
assert live_server._process
7367
assert live_server._process.is_alive()
74-
"""
75-
)
68+
""")
7669
result = appdir.runpytest("-v", "--start-live-server")
7770
result.stdout.fnmatch_lines(["*passed*"])
7871
assert result.ret == 0
@@ -103,8 +96,7 @@ def mocked_stop_cleanly(*args, **kwargs):
10396

10497
monkeypatch.setattr(LiveServer, "_stop_cleanly", mocked_stop_cleanly)
10598

106-
appdir.create_test_module(
107-
"""
99+
appdir.create_test_module("""
108100
import pytest
109101
110102
from flask import url_for
@@ -119,8 +111,7 @@ def index():
119111
res = client.get(url_for('index', _external=True))
120112
assert res.status_code == 200
121113
assert b'got it' in res.data
122-
"""
123-
)
114+
""")
124115
args = [] if clean_stop else ["--no-live-server-clean-stop"]
125116
result = appdir.runpytest_inprocess("-v", "--no-start-live-server", *args)
126117
result.stdout.fnmatch_lines("*1 passed*")
@@ -130,8 +121,7 @@ def index():
130121
assert stop_cleanly_result == []
131122

132123
def test_add_endpoint_to_live_server(self, appdir):
133-
appdir.create_test_module(
134-
"""
124+
appdir.create_test_module("""
135125
import pytest
136126
137127
from flask import url_for
@@ -146,16 +136,14 @@ def new_endpoint():
146136
res = client.get(url_for('new_endpoint', _external=True))
147137
assert res.status_code == 200
148138
assert b'got it' in res.data
149-
"""
150-
)
139+
""")
151140
result = appdir.runpytest("-v", "--no-start-live-server")
152141
result.stdout.fnmatch_lines(["*passed*"])
153142
assert result.ret == 0
154143

155144
@pytest.mark.skip("this test hangs in the original code")
156145
def test_concurrent_requests_to_live_server(self, appdir):
157-
appdir.create_test_module(
158-
"""
146+
appdir.create_test_module("""
159147
import pytest
160148
161149
from flask import url_for
@@ -175,51 +163,42 @@ def two():
175163
res = client.get(url_for('one', _external=True))
176164
assert res.status_code == 200
177165
assert b'42' in res.data
178-
"""
179-
)
166+
""")
180167
result = appdir.runpytest("-v", "--no-start-live-server")
181168
result.stdout.fnmatch_lines(["*passed*"])
182169
assert result.ret == 0
183170

184171
@pytest.mark.parametrize("port", [5000, 5001])
185172
def test_live_server_fixed_port(self, port, appdir):
186-
appdir.create_test_module(
187-
"""
173+
appdir.create_test_module("""
188174
import pytest
189175
190176
def test_port(live_server):
191177
assert live_server.port == %d
192-
"""
193-
% port
194-
)
178+
""" % port)
195179
result = appdir.runpytest("-v", "--live-server-port", str(port))
196180
result.stdout.fnmatch_lines(["*PASSED*"])
197181
assert result.ret == 0
198182

199183
@pytest.mark.parametrize("host", ["127.0.0.1", "0.0.0.0"])
200184
def test_live_server_fixed_host(self, host, appdir):
201-
appdir.create_test_module(
202-
"""
185+
appdir.create_test_module("""
203186
import pytest
204187
205188
def test_port(live_server):
206189
assert live_server.host == '%s'
207-
"""
208-
% host
209-
)
190+
""" % host)
210191
result = appdir.runpytest("-v", "--live-server-host", str(host))
211192
result.stdout.fnmatch_lines(["*PASSED*"])
212193
assert result.ret == 0
213194

214195
def test_respect_wait_timeout(self, appdir):
215-
appdir.create_test_module(
216-
"""
196+
appdir.create_test_module("""
217197
import pytest
218198
219199
def test_should_fail(live_server):
220200
assert live_server._process.is_alive()
221-
"""
222-
)
201+
""")
223202
result = appdir.runpytest("-v", "--live-server-wait=0.00000001")
224203
result.stdout.fnmatch_lines(["**ERROR**"])
225204
assert result.ret == 1

0 commit comments

Comments
 (0)