From cc536c8a7b6f61fedb2d0cb1abdd643d8e987afe Mon Sep 17 00:00:00 2001 From: Shipeng Feng Date: Sat, 2 Apr 2016 07:17:45 +0800 Subject: [PATCH] Fixed stream_with_context if decorated function has parameters --- flask/helpers.py | 2 +- tests/test_helpers.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flask/helpers.py b/flask/helpers.py index 3210772d..a7d8f97c 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -101,7 +101,7 @@ def stream_with_context(generator_or_function): gen = iter(generator_or_function) except TypeError: def decorator(*args, **kwargs): - gen = generator_or_function() + gen = generator_or_function(*args, **kwargs) return stream_with_context(gen) return update_wrapper(decorator, generator_or_function) diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 620fd792..2fe2ead5 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -683,11 +683,11 @@ class TestStreaming(object): @app.route('/') def index(): @flask.stream_with_context - def generate(): - yield 'Hello ' + def generate(hello): + yield hello yield flask.request.args['name'] yield '!' - return flask.Response(generate()) + return flask.Response(generate('Hello ')) c = app.test_client() rv = c.get('/?name=World') assert rv.data == b'Hello World!'