Browse Source

Modifications based on review

pull/2303/head
MikeTheReader 8 years ago
parent
commit
fd4a363657
  1. 44
      tests/test_helpers.py

44
tests/test_helpers.py

@ -945,49 +945,35 @@ class TestSafeJoin(object):
class TestHelpers(object): class TestHelpers(object):
def test_get_debug_flag(self): def test_get_debug_flag(self, monkeypatch):
original_debug_value = os.environ.get('FLASK_DEBUG') or '' monkeypatch.setenv('FLASK_DEBUG', '')
os.environ['FLASK_DEBUG'] = ''
assert get_debug_flag() == None assert get_debug_flag() == None
assert get_debug_flag(default=True) == True assert get_debug_flag(default=True) == True
os.environ['FLASK_DEBUG'] = '0' monkeypatch.setenv('FLASK_DEBUG', '0')
assert get_debug_flag() == False assert get_debug_flag() == False
assert get_debug_flag(default=True) == False assert get_debug_flag(default=True) == False
os.environ['FLASK_DEBUG'] = 'False' monkeypatch.setenv('FLASK_DEBUG', 'False')
assert get_debug_flag() == False assert get_debug_flag() == False
assert get_debug_flag(default=True) == False assert get_debug_flag(default=True) == False
os.environ['FLASK_DEBUG'] = 'No' monkeypatch.setenv('FLASK_DEBUG', 'No')
assert get_debug_flag() == False assert get_debug_flag() == False
assert get_debug_flag(default=True) == False assert get_debug_flag(default=True) == False
os.environ['FLASK_DEBUG'] = 'True' monkeypatch.setenv('FLASK_DEBUG', 'True')
assert get_debug_flag() == True assert get_debug_flag() == True
assert get_debug_flag(default=True) == True assert get_debug_flag(default=True) == True
os.environ['FLASK_DEBUG'] = original_debug_value def test_make_response(self):
def test_make_response_no_args(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
app.testing = True with app.test_request_context():
@app.route('/') rv = flask.helpers.make_response()
def index(): assert rv.status_code == 200
return flask.helpers.make_response() assert rv.mimetype == 'text/html'
c = app.test_client()
rv = c.get()
assert rv
def test_make_response_with_args(self): rv = flask.helpers.make_response('Hello')
app = flask.Flask(__name__) assert rv.status_code == 200
app.testing = True assert rv.data == b'Hello'
@app.route('/') assert rv.mimetype == 'text/html'
def index():
response = flask.helpers.make_response(flask.render_template_string('Hello World'))
response.headers['X-Parachutes'] = 'parachutes are cool'
return response
c = app.test_client()
rv = c.get()
assert rv
assert rv.headers['X-Parachutes'] == 'parachutes are cool'

Loading…
Cancel
Save