Skip to content
Myr

clean up new json tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent f16e477 · Browse files · 1 file+15 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−15 removed

  • tests:+15 added−15 removed

1 file+15 added−15 removed

modified:tests/test_helpers.py+15 added-15 removed
17 unmodified lines
18from logging import StreamHandler19from werkzeug.exceptions import BadRequest, NotFound20from werkzeug.http import parse_cache_control_header, parse_options_header21from werkzeug.http import http_date22from flask._compat import StringIO, text_type, PY222from flask._compat import StringIO, text_type232425def has_encoding(name):26 try:
74 unmodified lines
101 assert rv == u'"\u2603"'102103 def test_json_dump_to_file(self):104 app = flask.Flask(__name__)105 test_data = {'name': 'Flask'}106 out = StringIO()107106 test_data = {'lol': 'wut'}107108 with app.app_context():109 t_fh = open('test_json_dump_file', 'w')110 flask.json.dump(test_data, t_fh)111 t_fh.close()112113 t_fh = open('test_json_dump_file', 'r')114 rv = flask.json.load(t_fh)109 flask.json.dump(test_data, out)110 out.seek(0)111 rv = flask.json.load(out)112 assert rv == test_data116 t_fh.close()117 os.remove('test_json_dump_file')113114 def test_jsonify_basic_types(self):115 """Test jsonify with basic types."""116 # Should be able to use pytest parametrize on this, but I couldn't
68 unmodified lines
185 assert flask.json.loads(rv.data)['x'] == http_date(d.timetuple())186187 def test_jsonify_uuid_types(self):188 """Test jsonify with uuid.UUID types"""189190 test_uuid = uuid.UUID(bytes=b'\xDE\xAD\xBE\xEF'*4)191192 app = flask.Flask(__name__)197 c = app.test_client()193 url = '/uuid_test'199 app.add_url_rule(url, 'uuid_test', lambda val=test_uuid: flask.jsonify(x=val))194 app.add_url_rule(url, url, lambda: flask.jsonify(x=test_uuid))195196 c = app.test_client()197 rv = c.get(url)201 assert rv.mimetype == 'application/json'202 assert flask.json.loads(rv.data)['x'] == str(test_uuid)198199 rv_x = flask.json.loads(rv.data)['x']200 assert rv_x == str(test_uuid)201 rv_uuid = uuid.UUID(rv_x)202 assert rv_uuid == test_uuid203204 def test_json_attr(self):205 app = flask.Flask(__name__)206 @app.route('/add', methods=['POST'])207 def add():
600 unmodified lines