docstring_tokens stringlengths 0 76.5k | code_tokens stringlengths 75 1.81M | label_window listlengths 4 2.12k | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|---|
<mask> bp = flask.Blueprint('bp', __name__)
<mask> @bp.app_template_test('boolean')
<mask> def is_boolean(value):
<mask> return isinstance(value, bool)
<mask> app = flask.Flask(__name__)
<mask> app.register_blueprint(bp, url_prefix='/py')
<mask> @app.route('/')
<mask> def ind... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_blueprints.py | |
rv = client.get('/') | <mask> app.register_blueprint(bp, url_prefix='/py')
<mask> @app.route('/')
<mask> def index():
<mask> return flask.render_template('template_test.html', value=False)
<mask> rv = app.test_client().get('/')
<mask> assert b'Success!' in rv.data
<mask>
<mask> def test_add_template_test_... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_blueprints.py |
def test_add_template_test_with_name_and_template(app, client): | <mask> return flask.render_template('template_test.html', value=False)
<mask> rv = app.test_client().get('/')
<mask> assert b'Success!' in rv.data
<mask>
<mask> def test_add_template_test_with_name_and_template():
<mask> bp = flask.Blueprint('bp', __name__)
<mask> def is_boolean(value):
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_blueprints.py |
<mask> bp = flask.Blueprint('bp', __name__)
<mask> def is_boolean(value):
<mask> return isinstance(value, bool)
<mask> bp.add_app_template_test(is_boolean, 'boolean')
<mask> app = flask.Flask(__name__)
<mask> app.register_blueprint(bp, url_prefix='/py')
<mask> @app.route('/')
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_blueprints.py | |
rv = client.get('/') | <mask> app.register_blueprint(bp, url_prefix='/py')
<mask> @app.route('/')
<mask> def index():
<mask> return flask.render_template('template_test.html', value=False)
<mask> rv = app.test_client().get('/')
<mask> assert b'Success!' in rv.data
<mask>
<mask> def test_context_processing... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_blueprints.py |
def test_request_json(self, recwarn, app, client): | <mask> import flask
<mask>
<mask>
<mask> class TestRequestDeprecation(object):
<mask>
<mask> def test_request_json(self, recwarn):
<mask> """Request.json is deprecated"""
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask>
<mask> @app.route('/', methods... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_deprecations.py |
<mask> class TestRequestDeprecation(object):
<mask>
<mask> def test_request_json(self, recwarn):
<mask> """Request.json is deprecated"""
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask>
<mask> @app.route('/', methods=['POST'])
<mask> def index():... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_deprecations.py | |
client.post('/', data='{"spam": 42}', content_type='application/json') | <mask> assert flask.request.json == {'spam': 42}
<mask> print(flask.request.json)
<mask> return 'OK'
<mask>
<mask> c = app.test_client()
<mask> c.post('/', data='{"spam": 42}', content_type='application/json')
<mask> recwarn.pop(DeprecationWarning)
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_deprecations.py |
def test_request_module(self, recwarn, app, client): | <mask> c = app.test_client()
<mask> c.post('/', data='{"spam": 42}', content_type='application/json')
<mask> recwarn.pop(DeprecationWarning)
<mask>
<mask> def test_request_module(self, recwarn):
<mask> """Request.module is deprecated"""
<mask> app = flask.Flask(__name... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_deprecations.py |
<mask> recwarn.pop(DeprecationWarning)
<mask>
<mask> def test_request_module(self, recwarn):
<mask> """Request.module is deprecated"""
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask>
<mask> @app.route('/')
<mask> def index():
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_deprecations.py | |
client.get('/') | <mask> def index():
<mask> assert flask.request.module is None
<mask> return 'OK'
<mask>
<mask> c = app.test_client()
<mask> c.get('/')
<mask> recwarn.pop(DeprecationWarning)
</s> DRYing up the test suite using pytest fixtures (#2306)
* add fixtures to c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_deprecations.py |
def test_ignore_cached_json(self, app): | <mask> return False
<mask>
<mask>
<mask> class TestJSON(object):
<mask>
<mask> def test_ignore_cached_json(self):
<mask> app = flask.Flask(__name__)
<mask> with app.test_request_context('/', method='POST', data='malformed',
<mask> content_typ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_post_empty_json_adds_exception_to_response_content_in_debug(self, app, client): | <mask> assert flask.request.get_json(silent=True, cache=True) is None
<mask> with pytest.raises(BadRequest):
<mask> flask.request.get_json(silent=False, cache=False)
<mask>
<mask> def test_post_empty_json_adds_exception_to_response_content_in_debug(self):
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.post('/json', data=None, content_type='application/json') | <mask> @app.route('/json', methods=['POST'])
<mask> def post_json():
<mask> flask.request.get_json()
<mask> return None
<mask> c = app.test_client()
<mask> rv = c.post('/json', data=None, content_type='application/json')
<mask> assert rv.status_code... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_post_empty_json_wont_add_exception_to_response_if_no_debug(self, app, client): | <mask> rv = c.post('/json', data=None, content_type='application/json')
<mask> assert rv.status_code == 400
<mask> assert b'Failed to decode JSON object' in rv.data
<mask>
<mask> def test_post_empty_json_wont_add_exception_to_response_if_no_debug(self):
<mask> app = flask.Flas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.post('/json', data=None, content_type='application/json') | <mask> @app.route('/json', methods=['POST'])
<mask> def post_json():
<mask> flask.request.get_json()
<mask> return None
<mask> c = app.test_client()
<mask> rv = c.post('/json', data=None, content_type='application/json')
<mask> assert rv.status_code... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_json_bad_requests(self, app, client):
| <mask> rv = c.post('/json', data=None, content_type='application/json')
<mask> assert rv.status_code == 400
<mask> assert b'Failed to decode JSON object' not in rv.data
<mask>
<mask> def test_json_bad_requests(self):
<mask> app = flask.Flask(__name__)
<mask> @app.rout... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.post('/json', data='malformed', content_type='application/json') | <mask> app = flask.Flask(__name__)
<mask> @app.route('/json', methods=['POST'])
<mask> def return_json():
<mask> return flask.jsonify(foo=text_type(flask.request.get_json()))
<mask> c = app.test_client()
<mask> rv = c.post('/json', data='malformed', content_type... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_json_custom_mimetypes(self, app, client):
| <mask> c = app.test_client()
<mask> rv = c.post('/json', data='malformed', content_type='application/json')
<mask> assert rv.status_code == 400
<mask>
<mask> def test_json_custom_mimetypes(self):
<mask> app = flask.Flask(__name__)
<mask> @app.route('/json', methods=['... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.post('/json', data='"foo"', content_type='application/x+json') | <mask> app = flask.Flask(__name__)
<mask> @app.route('/json', methods=['POST'])
<mask> def return_json():
<mask> return flask.request.get_json()
<mask> c = app.test_client()
<mask> rv = c.post('/json', data='"foo"', content_type='application/x+json')
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_json_body_encoding(self, app, client): | <mask> c = app.test_client()
<mask> rv = c.post('/json', data='"foo"', content_type='application/x+json')
<mask> assert rv.data == b'foo'
<mask>
<mask> def test_json_body_encoding(self):
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> @app... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
app.config['JSON_AS_ASCII'] = test_value
rv = flask.json.dumps(u'\N{SNOWMAN}')
assert rv == expected | <mask>
<mask> def test_json_as_unicode(self):
<mask> app = flask.Flask(__name__)
<mask>
<mask> app.config['JSON_AS_ASCII'] = True
<mask> with app.app_context():
<mask> rv = flask.json.dumps(u'\N{SNOWMAN}')
<mask> assert rv == '"\\u2603"'
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_json_dump_to_file(self, app, app_ctx): | <mask> with app.app_context():
<mask> rv = flask.json.dumps(u'\N{SNOWMAN}')
<mask> assert rv == '"\\u2603"'
<mask>
<mask> app.config['JSON_AS_ASCII'] = False
<mask> with app.app_context():
<mask> rv = flask.json.dumps(u'\N{SNOWMAN}')
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
flask.json.dump(test_data, out)
out.seek(0)
rv = flask.json.load(out)
assert rv == test_data | <mask> app = flask.Flask(__name__)
<mask> test_data = {'name': 'Flask'}
<mask> out = StringIO()
<mask>
<mask> with app.app_context():
<mask> flask.json.dump(test_data, out)
<mask> out.seek(0)
<mask> rv = flask.json.load(out)
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_jsonify_basic_types(self, test_value, app, client): | <mask> rv = flask.json.load(out)
<mask> assert rv == test_data
<mask>
<mask> @pytest.mark.parametrize('test_value', [0, -1, 1, 23, 3.14, 's', "longer string", True, False, None])
<mask> def test_jsonify_basic_types(self, test_value):
<mask> """Test jsonify with basic types... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask>
<mask> @pytest.mark.parametrize('test_value', [0, -1, 1, 23, 3.14, 's', "longer string", True, False, None])
<mask> def test_jsonify_basic_types(self, test_value):
<mask> """Test jsonify with basic types."""
<mask> app = flask.Flask(__name__)
<mask> c = app.test_client()
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
rv = client.get(url) | <mask> c = app.test_client()
<mask>
<mask> url = '/jsonify_basic_types'
<mask> app.add_url_rule(url, url, lambda x=test_value: flask.jsonify(x))
<mask> rv = c.get(url)
<mask> assert rv.mimetype == 'application/json'
<mask> assert flask.json.loads(rv.data) == test_... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_jsonify_dicts(self, app, client): | <mask> rv = c.get(url)
<mask> assert rv.mimetype == 'application/json'
<mask> assert flask.json.loads(rv.data) == test_value
<mask>
<mask> def test_jsonify_dicts(self):
<mask> """Test jsonify with dicts and kwargs unpacking."""
<mask> d = dict(
<mask> a=0... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
d = {'a': 0, 'b': 23, 'c': 3.14, 'd': 't',
'e': 'Hi', 'f': True, 'g': False,
'h': ['test list', 10, False],
'i': {'test': 'dict'}}
| <mask> assert flask.json.loads(rv.data) == test_value
<mask>
<mask> def test_jsonify_dicts(self):
<mask> """Test jsonify with dicts and kwargs unpacking."""
<mask> d = dict(
<mask> a=0, b=23, c=3.14, d='t', e='Hi', f=True, g=False,
<mask> h=['test list', 10, F... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask> return flask.jsonify(**d)
<mask> @app.route('/dict')
<mask> def return_dict():
<mask> return flask.jsonify(d)
<mask> c = app.test_client()
<mask> for url in '/kw', '/dict':
<mask> rv = c.get(url)
<mask> assert rv.mimetype == ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
rv = client.get(url) | <mask> def return_dict():
<mask> return flask.jsonify(d)
<mask> c = app.test_client()
<mask> for url in '/kw', '/dict':
<mask> rv = c.get(url)
<mask> assert rv.mimetype == 'application/json'
<mask> assert flask.json.loads(rv.data) == d
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_jsonify_arrays(self, app, client): | <mask> rv = c.get(url)
<mask> assert rv.mimetype == 'application/json'
<mask> assert flask.json.loads(rv.data) == d
<mask>
<mask> def test_jsonify_arrays(self):
<mask> """Test jsonify of lists and args unpacking."""
<mask> l = [
<mask> 0, 42, ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
{'test': 'dict'} | <mask> """Test jsonify of lists and args unpacking."""
<mask> l = [
<mask> 0, 42, 3.14, 't', 'hello', True, False,
<mask> ['test list', 2, False],
<mask> {'test':'dict'}
<mask> ]
<mask> app = flask.Flask(__name__)
<mask> @app.route('/ar... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask> 0, 42, 3.14, 't', 'hello', True, False,
<mask> ['test list', 2, False],
<mask> {'test':'dict'}
<mask> ]
<mask> app = flask.Flask(__name__)
<mask> @app.route('/args_unpack')
<mask> def return_args_unpack():
<mask> return flask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
<mask> return flask.jsonify(*l)
<mask> @app.route('/array')
<mask> def return_array():
<mask> return flask.jsonify(l)
<mask> c = app.test_client()
<mask> for url in '/args_unpack', '/array':
<mask> rv = c.get(url)
<mask> assert rv.m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
rv = client.get(url) | <mask> def return_array():
<mask> return flask.jsonify(l)
<mask> c = app.test_client()
<mask> for url in '/args_unpack', '/array':
<mask> rv = c.get(url)
<mask> assert rv.mimetype == 'application/json'
<mask> assert flask.json.loads(rv.data)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_jsonify_date_types(self, app, client): | <mask> rv = c.get(url)
<mask> assert rv.mimetype == 'application/json'
<mask> assert flask.json.loads(rv.data) == l
<mask>
<mask> def test_jsonify_date_types(self):
<mask> """Test jsonify with datetime.date and datetime.datetime types."""
<mask> test_dates... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask> test_dates = (
<mask> datetime.datetime(1973, 3, 11, 6, 30, 45),
<mask> datetime.date(1975, 1, 5)
<mask> )
<mask> app = flask.Flask(__name__)
<mask> c = app.test_client()
<mask>
<mask> for i, d in enumerate(test_dates):
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
rv = client.get(url) | <mask>
<mask> for i, d in enumerate(test_dates):
<mask> url = '/datetest{0}'.format(i)
<mask> app.add_url_rule(url, str(i), lambda val=d: flask.jsonify(x=val))
<mask> rv = c.get(url)
<mask> assert rv.mimetype == 'application/json'
<mask> assert... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_jsonify_uuid_types(self, app, client): | <mask> rv = c.get(url)
<mask> assert rv.mimetype == 'application/json'
<mask> assert flask.json.loads(rv.data)['x'] == http_date(d.timetuple())
<mask>
<mask> def test_jsonify_uuid_types(self):
<mask> """Test jsonify with uuid.UUID types"""
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask> def test_jsonify_uuid_types(self):
<mask> """Test jsonify with uuid.UUID types"""
<mask>
<mask> test_uuid = uuid.UUID(bytes=b'\xDE\xAD\xBE\xEF' * 4)
<mask> app = flask.Flask(__name__)
<mask> url = '/uuid_test'
<mask> app.add_url_rule(url, url, lambda: flask.jso... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
rv = client.get(url) | <mask> app = flask.Flask(__name__)
<mask> url = '/uuid_test'
<mask> app.add_url_rule(url, url, lambda: flask.jsonify(x=test_uuid))
<mask>
<mask> c = app.test_client()
<mask> rv = c.get(url)
<mask>
<mask> rv_x = flask.json.loads(rv.data)['x']
<mask> asse... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_json_attr(self, app, client):
| <mask> assert rv_x == str(test_uuid)
<mask> rv_uuid = uuid.UUID(rv_x)
<mask> assert rv_uuid == test_uuid
<mask>
<mask> def test_json_attr(self):
<mask> app = flask.Flask(__name__)
<mask> @app.route('/add', methods=['POST'])
<mask> def add():
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.post('/add', data=flask.json.dumps({'a': 1, 'b': 2}),
content_type='application/json') | <mask> @app.route('/add', methods=['POST'])
<mask> def add():
<mask> json = flask.request.get_json()
<mask> return text_type(json['a'] + json['b'])
<mask> c = app.test_client()
<mask> rv = c.post('/add', data=flask.json.dumps({'a': 1, 'b': 2}),
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_template_escaping(self, app, req_ctx): | <mask> rv = c.post('/add', data=flask.json.dumps({'a': 1, 'b': 2}),
<mask> content_type='application/json')
<mask> assert rv.data == b'3'
<mask>
<mask> def test_template_escaping(self):
<mask> app = flask.Flask(__name__)
<mask> render = flask.rende... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = flask.json.htmlsafe_dumps('</script>')
assert rv == u'"\\u003c/script\\u003e"'
assert type(rv) == text_type
rv = render('{{ "</script>"|tojson }}')
assert rv == '"\\u003c/script\\u003e"'
rv = render('{{ "<\0/script>"|tojson }}')
assert rv == '"\\u003c\\u0000/... | <mask>
<mask> def test_template_escaping(self):
<mask> app = flask.Flask(__name__)
<mask> render = flask.render_template_string
<mask> with app.test_request_context():
<mask> rv = flask.json.htmlsafe_dumps('</script>')
<mask> assert rv == u'"\\u003c/script\\u0... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
... | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask> def object_hook(self, obj):
<mask> if len(obj) == 1 and '_foo' in obj:
<mask> return X(obj['_foo'])
<mask> return obj
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> app.json_encoder = MyEncoder
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
rv = client.post('/', data=flask.json.dumps({ | <mask> app.json_decoder = MyDecoder
<mask> @app.route('/', methods=['POST'])
<mask> def index():
<mask> return flask.json.dumps(flask.request.get_json()['x'])
<mask> c = app.test_client()
<mask> rv = c.post('/', data=flask.json.dumps({
<mask> 'x': {... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_blueprint_json_customization(self, app, client): | <mask> 'x': {'_foo': 42}
<mask> }), content_type='application/json')
<mask> assert rv.data == b'"<42>"'
<mask>
<mask> def test_blueprint_json_customization(self):
<mask> class X(object):
<mask> def __init__(self, val):
<mask> self.val = val
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask> @bp.route('/bp', methods=['POST'])
<mask> def index():
<mask> return flask.json.dumps(flask.request.get_json()['x'])
<mask>
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> app.register_blueprint(bp)
<mask>
<mask> c = app.t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
rv = client.post('/bp', data=flask.json.dumps({ | <mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> app.register_blueprint(bp)
<mask>
<mask> c = app.test_client()
<mask> rv = c.post('/bp', data=flask.json.dumps({
<mask> 'x': {'_foo': 42}
<mask> }), content_type='application/json')
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_modified_url_encoding(self, app): | <mask> 'x': {'_foo': 42}
<mask> }), content_type='application/json')
<mask> assert rv.data == b'"<42>"'
<mask>
<mask> def test_modified_url_encoding(self):
<mask> class ModifiedRequest(flask.Request):
<mask> url_charset = 'euc-kr'
<mask> app = flask.F... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask>
<mask> def test_modified_url_encoding(self):
<mask> class ModifiedRequest(flask.Request):
<mask> url_charset = 'euc-kr'
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> app.request_class = ModifiedRequest
<mask> app.url_map.chars... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
def test_json_key_sorting(self, app, client): | <mask>
<mask> if not has_encoding('euc-kr'):
<mask> test_modified_url_encoding = None
<mask>
<mask> def test_json_key_sorting(self):
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> app.debug = True
<mask>
<mask> assert app.config['JSON_SOR... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/') | <mask> @app.route('/')
<mask> def index():
<mask> return flask.jsonify(values=d)
<mask>
<mask> c = app.test_client()
<mask> rv = c.get('/')
<mask> lines = [x.strip() for x in rv.data.strip().decode('utf-8').splitlines()]
<mask> sorted_by_str = [
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask> assert lines == sorted_by_int
<mask> except AssertionError:
<mask> assert lines == sorted_by_str
<mask>
<mask> class TestSendfile(object):
<mask>
<mask> def test_send_file_regular(self):
<mask> app = flask.Flask(__name__)
<mask> with app.test_request... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
class TestSendfile(object):
def test_send_file_regular(self, app, req_ctx):
rv = flask.send_file('static/index.html')
assert rv.direct_passthrough
assert rv.mimetype == 'text/html'
with app.open_resource('static/index.html') as f:
rv.direct_passthrough = False
... | <mask> assert lines == sorted_by_str
<mask>
<mask> class TestSendfile(object):
<mask>
<mask> def test_send_file_regular(self):
<mask> app = flask.Flask(__name__)
<mask> with app.test_request_context():
<mask> rv = flask.send_file('static/index.html')
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_send_file_xsendfile(self, app, req_ctx, catch_deprecation_warnings): | <mask> rv.direct_passthrough = False
<mask> assert rv.data == f.read()
<mask> rv.close()
<mask>
<mask> def test_send_file_xsendfile(self, catch_deprecation_warnings):
<mask> app = flask.Flask(__name__)
<mask> app.use_x_sendfile = True
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = flask.send_file('static/index.html')
assert rv.direct_passthrough
assert 'x-sendfile' in rv.headers
assert rv.headers['x-sendfile'] == \
os.path.join(app.root_path, 'static/index.html')
assert rv.mimetype == 'text/html'
rv.close() | <mask>
<mask> def test_send_file_xsendfile(self, catch_deprecation_warnings):
<mask> app = flask.Flask(__name__)
<mask> app.use_x_sendfile = True
<mask> with app.test_request_context():
<mask> rv = flask.send_file('static/index.html')
<mask> assert rv.direct_p... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_send_file_last_modified(self, app, client): | <mask> os.path.join(app.root_path, 'static/index.html')
<mask> assert rv.mimetype == 'text/html'
<mask> rv.close()
<mask>
<mask> def test_send_file_last_modified(self):
<mask> app = flask.Flask(__name__)
<mask> last_modified = datetime.datetime(1999, 1... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/') | <mask> return flask.send_file(StringIO("party like it's"),
<mask> last_modified=last_modified,
<mask> mimetype='text/plain')
<mask>
<mask> c = app.test_client()
<mask> rv = c.get('/')
<mask> assert rv.last_... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_send_file_object_without_mimetype(self, app, req_ctx):
with pytest.raises(ValueError) as excinfo:
flask.send_file(StringIO("LOL"))
assert 'Unable to infer MIME-type' in str(excinfo)
assert 'no filename is available' in str(excinfo) | <mask> c = app.test_client()
<mask> rv = c.get('/')
<mask> assert rv.last_modified == last_modified
<mask>
<mask> def test_send_file_object_without_mimetype(self):
<mask> app = flask.Flask(__name__)
<mask>
<mask> with app.test_request_context():
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
flask.send_file(StringIO("LOL"), attachment_filename='filename') | <mask>
<mask> with app.test_request_context():
<mask> flask.send_file(StringIO("LOL"), attachment_filename='filename')
<mask>
<mask> def test_send_file_object(self):
<mask> app = flask.Flask(__name__)
<mask>
<mask> with app.test_request_context():
<mask> w... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_send_file_object(self, app, req_ctx):
with open(os.path.join(app.root_path, 'static/index.html'), mode='rb') as f:
rv = flask.send_file(f, mimetype='text/html')
rv.direct_passthrough = False
with app.open_resource('static/index.html') as f:
assert... | <mask>
<mask> def test_send_file_object(self):
<mask> app = flask.Flask(__name__)
<mask>
<mask> with app.test_request_context():
<mask> with open(os.path.join(app.root_path, 'static/index.html'), mode='rb') as f:
<mask> rv = flask.send_file(f, mimetype='text/html... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
with open(os.path.join(app.root_path, 'static/index.html')) as f:
rv = flask.send_file(f, mimetype='text/html')
assert rv.mimetype == 'text/html'
assert 'x-sendfile' not in rv.headers
rv.close() | <mask> rv.close()
<mask>
<mask> app.use_x_sendfile = True
<mask>
<mask> with app.test_request_context():
<mask> with open(os.path.join(app.root_path, 'static/index.html')) as f:
<mask> rv = flask.send_file(f, mimetype='text/html')
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
f = StringIO('Test')
rv = flask.send_file(f, mimetype='application/octet-stream')
rv.direct_passthrough = False
assert rv.data == b'Test'
assert rv.mimetype == 'application/octet-stream'
rv.close() | <mask> assert 'x-sendfile' not in rv.headers
<mask> rv.close()
<mask>
<mask> app.use_x_sendfile = False
<mask> with app.test_request_context():
<mask> f = StringIO('Test')
<mask> rv = flask.send_file(f, mimetype='application/octet-stream')
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
class PyStringIO(object):
def __init__(self, *args, **kwargs):
self._io = StringIO(*args, **kwargs) | <mask> assert rv.data == b'Test'
<mask> assert rv.mimetype == 'application/octet-stream'
<mask> rv.close()
<mask>
<mask> class PyStringIO(object):
<mask> def __init__(self, *args, **kwargs):
<mask> self._io = StringIO(*args, **k... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def __getattr__(self, name):
return getattr(self._io, name)
f = PyStringIO('Test')
f.name = 'test.txt'
rv = flask.send_file(f, attachment_filename=f.name)
rv.direct_passthrough = False
assert rv.data == b'Test'
assert rv.mimetype == 'text/plai... | <mask> assert rv.data == b'Test'
<mask> assert rv.mimetype == 'text/plain'
<mask> rv.close()
<mask>
<mask> f = StringIO('Test')
<mask> rv = flask.send_file(f, mimetype='text/plain')
<mask> rv.direct_passthrough = False
<mask> a... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
f = StringIO('Test')
rv = flask.send_file(f, mimetype='text/html')
assert 'x-sendfile' not in rv.headers
rv.close() | <mask> rv.close()
<mask>
<mask> app.use_x_sendfile = True
<mask>
<mask> with app.test_request_context():
<mask> f = StringIO('Test')
<mask> rv = flask.send_file(f, mimetype='text/html')
<mask> assert 'x-sendfile' not in rv.headers
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_send_file_range_request(self, app, client): | <mask> @pytest.mark.skipif(
<mask> not callable(getattr(Range, 'to_content_range_header', None)),
<mask> reason="not implement within werkzeug"
<mask> )
<mask> def test_send_file_range_request(self):
<mask> app = flask.Flask(__name__)
<mask>
<mask> @app.route('/')
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/', headers={'Range': 'bytes=4-15'}) | <mask> @app.route('/')
<mask> def index():
<mask> return flask.send_file('static/index.html', conditional=True)
<mask>
<mask> c = app.test_client()
<mask>
<mask> rv = c.get('/', headers={'Range': 'bytes=4-15'})
<mask> assert rv.status_code == 206
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/', headers={'Range': 'bytes=4-'}) | <mask> with app.open_resource('static/index.html') as f:
<mask> assert rv.data == f.read()[4:16]
<mask> rv.close()
<mask>
<mask> rv = c.get('/', headers={'Range': 'bytes=4-'})
<mask> assert rv.status_code == 206
<mask> with app.open_resource('static/index.html... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/', headers={'Range': 'bytes=4-1000'}) | <mask> with app.open_resource('static/index.html') as f:
<mask> assert rv.data == f.read()[4:]
<mask> rv.close()
<mask>
<mask> rv = c.get('/', headers={'Range': 'bytes=4-1000'})
<mask> assert rv.status_code == 206
<mask> with app.open_resource('static/index.ht... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/', headers={'Range': 'bytes=-10'}) | <mask> with app.open_resource('static/index.html') as f:
<mask> assert rv.data == f.read()[4:]
<mask> rv.close()
<mask>
<mask> rv = c.get('/', headers={'Range': 'bytes=-10'})
<mask> assert rv.status_code == 206
<mask> with app.open_resource('static/index.html'... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/', headers={'Range': 'bytes=1000-'}) | <mask> with app.open_resource('static/index.html') as f:
<mask> assert rv.data == f.read()[-10:]
<mask> rv.close()
<mask>
<mask> rv = c.get('/', headers={'Range': 'bytes=1000-'})
<mask> assert rv.status_code == 416
<mask> rv.close()
<mask>
<mask> rv... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/', headers={'Range': 'bytes=-'}) | <mask> rv = c.get('/', headers={'Range': 'bytes=1000-'})
<mask> assert rv.status_code == 416
<mask> rv.close()
<mask>
<mask> rv = c.get('/', headers={'Range': 'bytes=-'})
<mask> assert rv.status_code == 416
<mask> rv.close()
<mask>
<mask> rv = c.get('/'... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/', headers={'Range': 'somethingsomething'}) | <mask> rv = c.get('/', headers={'Range': 'bytes=-'})
<mask> assert rv.status_code == 416
<mask> rv.close()
<mask>
<mask> rv = c.get('/', headers={'Range': 'somethingsomething'})
<mask> assert rv.status_code == 416
<mask> rv.close()
<mask>
<mask> last_mo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/', headers={'Range': 'bytes=4-15',
'If-Range': http_date(last_modified)}) | <mask> last_modified = datetime.datetime.utcfromtimestamp(os.path.getmtime(
<mask> os.path.join(app.root_path, 'static/index.html'))).replace(
<mask> microsecond=0)
<mask>
<mask> rv = c.get('/', headers={'Range': 'bytes=4-15',
<mask> 'If-Ra... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/', headers={'Range': 'bytes=4-15', 'If-Range': http_date( | <mask> 'If-Range': http_date(last_modified)})
<mask> assert rv.status_code == 206
<mask> rv.close()
<mask>
<mask> rv = c.get('/', headers={'Range': 'bytes=4-15', 'If-Range': http_date(
<mask> datetime.datetime(1999, 1, 1))})
<mask> ass... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_attachment(self, app, req_ctx): | <mask> datetime.datetime(1999, 1, 1))})
<mask> assert rv.status_code == 200
<mask> rv.close()
<mask>
<mask> def test_attachment(self):
<mask> app = flask.Flask(__name__)
<mask> with app.test_request_context():
<mask> with open(os.path.join(app.root_pa... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask> rv.close()
<mask>
<mask> def test_attachment(self):
<mask> app = flask.Flask(__name__)
<mask> with app.test_request_context():
<mask> with open(os.path.join(app.root_path, 'static/index.html')) as f:
<mask> rv = flask.send_file(f, as_attachment=True... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
with open(os.path.join(app.root_path, 'static/index.html')) as f:
rv = flask.send_file(f, as_attachment=True,
attachment_filename='index.html')
value, options = \
parse_options_header(rv.headers['Content-Disposition']) | <mask> assert options['filename'] == 'index.html'
<mask> assert 'filename*' not in rv.headers['Content-Disposition']
<mask> rv.close()
<mask>
<mask> with app.test_request_context():
<mask> rv = flask.send_file('static/index.html', as_attachment=... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
assert 'filename*' not in rv.headers['Content-Disposition'] | <mask> value, options = \
<mask> parse_options_header(rv.headers['Content-Disposition'])
<mask> assert value == 'attachment'
<mask> assert options['filename'] == 'index.html'
<mask> rv.close()
<mask>
<mask> rv = flask.send_file('static/inde... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = flask.send_file('static/index.html', as_attachment=True)
value, options = parse_options_header(rv.headers['Content-Disposition'])
assert value == 'attachment'
assert options['filename'] == 'index.html'
rv.close() | <mask> assert value == 'attachment'
<mask> assert options['filename'] == 'index.html'
<mask> rv.close()
<mask>
<mask> with app.test_request_context():
<mask> rv = flask.send_file(StringIO('Test'), as_attachment=True,
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_static_file(self, app, req_ctx): | <mask> "filename*=UTF-8''%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt"
<mask> ))
<mask> rv.close()
<mask>
<mask> def test_static_file(self):
<mask> app = flask.Flask(__name__)
<mask> # default cache timeout is 12 hours
<mask> with app.test_reques... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
# Test with static file handler.
rv = app.send_static_file('index.html')
cc = parse_cache_control_header(rv.headers['Cache-Control'])
assert cc.max_age == 12 * 60 * 60
rv.close()
# Test again with direct use of send_file utility.
rv = flask.send_file('static/index... | <mask>
<mask> def test_static_file(self):
<mask> app = flask.Flask(__name__)
<mask> # default cache timeout is 12 hours
<mask> with app.test_request_context():
<mask> # Test with static file handler.
<mask> rv = app.send_static_file('index.html')
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
# Test with static file handler.
rv = app.send_static_file('index.html')
cc = parse_cache_control_header(rv.headers['Cache-Control'])
assert cc.max_age == 3600
rv.close()
# Test again with direct use of send_file utility.
rv = flask.send_file('static/index.html')
... | <mask> cc = parse_cache_control_header(rv.headers['Cache-Control'])
<mask> assert cc.max_age == 12 * 60 * 60
<mask> rv.close()
<mask> app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 3600
<mask> with app.test_request_context():
<mask> # Test with static fil... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_send_from_directory(self, app, req_ctx): | <mask> cc = parse_cache_control_header(rv.headers['Cache-Control'])
<mask> assert cc.max_age == 10
<mask> rv.close()
<mask>
<mask> def test_send_from_directory(self):
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> app.root_pat... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = flask.send_from_directory('static', 'hello.txt')
rv.direct_passthrough = False
assert rv.data.strip() == b'Hello Subdomain'
rv.close() | <mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> app.root_path = os.path.join(os.path.dirname(__file__),
<mask> 'test_apps', 'subdomaintestmodule')
<mask> with app.test_request_context():
<mask> rv = flask.send_fro... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_send_from_directory_bad_request(self, app, req_ctx): | <mask> rv.direct_passthrough = False
<mask> assert rv.data.strip() == b'Hello Subdomain'
<mask> rv.close()
<mask>
<mask> def test_send_from_directory_bad_request(self):
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> app.root_p... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask> app = flask.Flask(__name__)
<mask> app.testing = True
<mask> app.root_path = os.path.join(os.path.dirname(__file__),
<mask> 'test_apps', 'subdomaintestmodule')
<mask> with app.test_request_context():
<mask> with pytest.raises(... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
with pytest.raises(BadRequest):
flask.send_from_directory('static', 'bad\x00')
| <mask> with app.test_request_context():
<mask> with pytest.raises(BadRequest):
<mask> flask.send_from_directory('static', 'bad\x00')
<mask>
<mask> class TestLogging(object):
<mask>
<mask> def test_logger_cache(self):
<mask> app = flask.Flask(__name__)
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
class TestLogging(object): | <mask> with pytest.raises(BadRequest):
<mask> flask.send_from_directory('static', 'bad\x00')
<mask>
<mask>
<mask> def test_logger_cache(self):
<mask> app = flask.Flask(__name__)
<mask> logger1 = app.logger
<mask> assert app.logger is logger1
</s> DRYing up the ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_debug_log_override(self, app): | <mask>
<mask> with pytest.raises(ZeroDivisionError):
<mask> c.get('/exc')
<mask>
<mask> def test_debug_log_override(self):
<mask> app = flask.Flask(__name__)
<mask> app.debug = True
<mask> app.logger_name = 'flask_tests/test_debug_log_override'
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_exception_logging(self, app): | <mask> app.logger_name = 'flask_tests/test_debug_log_override'
<mask> app.logger.level = 10
<mask> assert app.logger.level == 10
<mask>
<mask> def test_exception_logging(self):
<mask> out = StringIO()
<mask> app = flask.Flask(__name__)
<mask> app.config['LOGG... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
<mask> assert app.logger.level == 10
<mask>
<mask> def test_exception_logging(self):
<mask> out = StringIO()
<mask> app = flask.Flask(__name__)
<mask> app.config['LOGGER_HANDLER_POLICY'] = 'never'
<mask> app.logger_name = 'flask_tests/test_exception_logging'
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py | |
app.testing = False | <mask> out = StringIO()
<mask> app.config['LOGGER_HANDLER_POLICY'] = 'never'
<mask> app.logger_name = 'flask_tests/test_exception_logging'
<mask> app.logger.addHandler(StreamHandler(out))
<mask>
<mask> @app.route('/')
<mask> def index():
<mask> 1 // 0... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
def test_processor_exceptions(self, app, client): | <mask> assert 'Traceback (most recent call last):' in err
<mask> assert '1 // 0' in err
<mask> assert 'ZeroDivisionError:' in err
<mask>
<mask> def test_processor_exceptions(self):
<mask> app = flask.Flask(__name__)
<mask> app.config['LOGGER_HANDLER_POLICY'] = 'never'... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
app.testing = False
| <mask> assert 'ZeroDivisionError:' in err
<mask>
<mask> def test_processor_exceptions(self, app, client):
<mask> app.config['LOGGER_HANDLER_POLICY'] = 'never'
<mask> @app.before_request
<mask> def before_request():
<mask> if trigger == 'before':
<mask> ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
rv = client.get('/') | <mask> @app.errorhandler(500)
<mask> def internal_server_error(e):
<mask> return 'Hello Server Error', 500
<mask> for trigger in 'before', 'after':
<mask> rv = app.test_client().get('/')
<mask> assert rv.status_code == 500
<mask> assert rv.d... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/5b0b9717da958fd6325c675d92be4f6667796112 | tests/test_helpers.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.