Skip to content

Commit e1b7b40

Browse files
committed
Ensure the live server can handle concurrent requests, as per #56
1 parent d8e9c97 commit e1b7b40

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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)