forked from orbit-oss/flask
Fixed a broken test
This commit is contained in:
parent
fb622380d0
commit
ddb5f9dc49
1 changed files with 6 additions and 6 deletions
|
|
@ -11,11 +11,12 @@
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
|
import time
|
||||||
import flask
|
import flask
|
||||||
import pickle
|
import pickle
|
||||||
import unittest
|
import unittest
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from threading import Thread, Condition
|
from threading import Thread
|
||||||
from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning
|
from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning
|
||||||
from flask._compat import text_type
|
from flask._compat import text_type
|
||||||
from werkzeug.exceptions import BadRequest, NotFound
|
from werkzeug.exceptions import BadRequest, NotFound
|
||||||
|
|
@ -1018,18 +1019,17 @@ class BasicFunctionalityTestCase(FlaskTestCase):
|
||||||
def test_before_first_request_functions_concurrent(self):
|
def test_before_first_request_functions_concurrent(self):
|
||||||
got = []
|
got = []
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
cv = Condition()
|
|
||||||
@app.before_first_request
|
@app.before_first_request
|
||||||
def foo():
|
def foo():
|
||||||
with cv:
|
time.sleep(0.2)
|
||||||
cv.wait()
|
|
||||||
got.append(42)
|
got.append(42)
|
||||||
|
|
||||||
c = app.test_client()
|
c = app.test_client()
|
||||||
def get_and_assert():
|
def get_and_assert():
|
||||||
with cv:
|
|
||||||
cv.notify()
|
|
||||||
c.get("/")
|
c.get("/")
|
||||||
self.assert_equal(got, [42])
|
self.assert_equal(got, [42])
|
||||||
|
|
||||||
t = Thread(target=get_and_assert)
|
t = Thread(target=get_and_assert)
|
||||||
t.start()
|
t.start()
|
||||||
get_and_assert()
|
get_and_assert()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue