I'm writing "unittests" for my flask api. Using Flask.test_client() is easy locally. eg:
app = Flask(__name__)
client = app.test_client()
However, I want to still be able to do things such as
self.client.post('{0}/account/password'.format(self.base_path),
data=json.dumps(passwordu), headers=self.get_headers(),
content_type=self.content_type)
But I want the client to talk to a remote host.
I've seen I can use environ_override as a parameter to the client.post(...) method. To me there must be a simpler way to get a simple client that does the necessary sending of requests and decoding of responses in the same way test_client() does. However, subclassing client, still requires me to use a Flask instance.
Aucun commentaire:
Enregistrer un commentaire