Skip to content

Instantly share code, notes, and snippets.

@moqada
Created December 17, 2013 18:10
Show Gist options
  • Select an option

  • Save moqada/8009789 to your computer and use it in GitHub Desktop.

Select an option

Save moqada/8009789 to your computer and use it in GitHub Desktop.
import flask
app = flask.Flask(__name__)
def test_user_agent():
ua = 'MySuperBrowser; 0.1;'
app.test_request_context(
environ_base={'HTTP_USER_AGENT': ua}
)
assert flask.request.headers.get('User-Agent') == ua
def test_path():
path = '/foo/bar/?spam=egg'
app.test_request_context(path)
assert flask.request.path == path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment