We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider the following app:
import unittest from flask import Flask, g, request from flask_testing.utils import TestCase def create_app(): app = Flask(__name__) @app.route('/', methods=['POST']) def index(): try: result = g.dejavu except AttributeError: result = '?' g.dejavu = request.json['dejavu'] return result return app app = create_app() class MyTestCase(TestCase): def create_app(self): return create_app() def test(self): with self.app.test_client() as client: response = client.post('/', json={'dejavu': '42'}) self.assert200(response) self.assertEqual(b'?', response.data) response = client.post('/', json={'dejavu': '42'}) self.assert200(response) self.assertEqual(b'?', response.data) if __name__ == '__main__': unittest.main()
flask --app foo run works as expected:
flask --app foo run
$ curl http://127.0.0.1:5000 -H 'Content-Type: application/json' --data '{"dejavu": 42}' ? $ curl http://127.0.0.1:5000 -H 'Content-Type: application/json' --data '{"dejavu": 42}' ?
However, the respective test fails:
$ python3 foo.py # AssertionError: b'?' != b'42'
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Consider the following app:
flask --app foo run
works as expected:However, the respective test fails:
The text was updated successfully, but these errors were encountered: