Skip to content

Commit a392889

Browse files
authored
Merge pull request #57 from pytest-dev/56-ensure-the-live-server-can-process-concurrent-requests
Ensure the live server can process concurrent requests
2 parents d8e9c97 + 6c17267 commit a392889

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

docs/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Changelog
66
Upcoming release
77
-----------------
88

9+
- Allow live server to handle concurrent requests (`#56`_), thanks to
10+
`@mattwbarry`_ for the PR.
11+
912
- Fix broken link to pytest documentation (`#50`_), thanks to
1013
`@jineshpaloor`_ for the PR.
1114

@@ -21,8 +24,10 @@ Upcoming release
2124
.. _#43: https://github.com/vitalk/pytest-flask/issues/43
2225
.. _#48: https://github.com/pytest-dev/pytest-flask/pull/48
2326
.. _#50: https://github.com/pytest-dev/pytest-flask/pull/50
27+
.. _#56: https://github.com/pytest-dev/pytest-flask/pull/56
2428
.. _@danstender: https://github.com/danstender
2529
.. _@jineshpaloor: https://github.com/jineshpaloor
30+
.. _@mattwbarry: https://github.com/mattwbarry
2631
.. _@steenzout: https://github.com/steenzout
2732

2833

tests/test_live_server.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,33 @@ def new_endpoint():
8282
result = appdir.runpytest('-v', '--no-start-live-server')
8383
result.stdout.fnmatch_lines(['*PASSED*'])
8484
assert result.ret == 0
85+
86+
def test_concurrent_requests_to_live_server(self, appdir):
87+
appdir.create_test_module('''
88+
import pytest
89+
try:
90+
from urllib2 import urlopen
91+
except ImportError:
92+
from urllib.request import urlopen
93+
94+
from flask import url_for
95+
96+
def test_concurrent_requests(live_server):
97+
@live_server.app.route('/one')
98+
def one():
99+
res = urlopen(url_for('two', _external=True))
100+
return res.read()
101+
102+
@live_server.app.route('/two')
103+
def two():
104+
return '42'
105+
106+
live_server.start()
107+
108+
res = urlopen(url_for('one', _external=True))
109+
assert res.code == 200
110+
assert b'42' in res.read()
111+
''')
112+
result = appdir.runpytest('-v', '--no-start-live-server')
113+
result.stdout.fnmatch_lines(['*PASSED*'])
114+
assert result.ret == 0

0 commit comments

Comments
 (0)