How to apply integration tests (rather than unit tests) to a Flask RESTful API

后端 未结 4 1623
不知归路
不知归路 2020-12-14 01:36

[As per https://stackoverflow.com/a/46369945/1021819, the title should refer to integration tests rather than unit tests]

Suppose I\'d like to test the foll

4条回答
  •  难免孤独
    2020-12-14 02:33

    With Python3, I got the error TypeError: the JSON object must be str, not bytes. It is required to decode:

    # in TestFlaskApi.test_hello_world
    self.assertEqual(json.loads(response.get_data().decode()), {'hello': 'world'})
    

    This question gives an explanation.

提交回复
热议问题