Skip to content

Commit d6b7d51

Browse files
committed
Ignore flask development warnings.
We used to dodge these by listening on 0.0.0.0. Now they are on to us and always show the warnings. Running flask in development mode here is intended, so lets not have the warnings fail the tests. Ref: pallets/werkzeug#2480
1 parent b731fb4 commit d6b7d51

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/end2end/fixtures/webserver.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from PyQt5.QtCore import pyqtSignal, QUrl
3232

3333
from end2end.fixtures import testprocess
34+
from helpers import testutils
3435

3536

3637
class Request(testprocess.Line):
@@ -125,6 +126,18 @@ def __eq__(self, other):
125126
return NotImplemented
126127

127128

129+
def is_flask_development_message(message):
130+
ignored_messages = [
131+
("WARNING: This is a development server. Do not use it in a production "
132+
"deployment. Use a production WSGI server instead."),
133+
"Press CTRL+C to quit",
134+
]
135+
return any(
136+
testutils.pattern_match(pattern=pattern, value=message)
137+
for pattern in ignored_messages
138+
)
139+
140+
128141
class WebserverProcess(testprocess.Process):
129142

130143
"""Abstraction over a running Flask server process.
@@ -160,8 +173,12 @@ def get_requests(self):
160173

161174
def _parse_line(self, line):
162175
self._log(line)
163-
started_re = re.compile(r' \* Running on https?://127\.0\.0\.1:{}/? '
164-
r'\(Press CTRL\+C to quit\)'.format(self.port))
176+
177+
if is_flask_development_message(line):
178+
return None
179+
180+
started_re = re.compile(r' \* Running on https?://127\.0\.0\.1:{}/?'
181+
r'( \(Press CTRL\+C to quit\))?'.format(self.port))
165182
if started_re.fullmatch(line):
166183
self.ready.emit()
167184
return None

0 commit comments

Comments
 (0)