My application depends on request.remote_addr
which is None
when i run tests through nosetests which uses app.test_client().post('/users/login', ....)
.
How can I emulate an IP (127.0.0.1 works fine) when I run tests? I've tried setting environment variables, sent in headers with the post() method and I've digged through nosetests, werkzeugs and flasks documentation but nothing I've tried has worked.
You can set options for the underlying Werkzeug environment using environ_base:
A friend gave me this solution, which works across all requests: