Which is the better way to pass data into Python Unittest Redirected STDIN or Pickle?

前端 未结 1 1068
时光说笑
时光说笑 2021-01-13 06:44

Short Question
What is the best way to get data into a Python unittest case ?

Background
My project is using Python\'s unit

相关标签:
1条回答
  • 2021-01-13 07:13

    I have created unittests which test against a third party service (Zoho CRM). To test the service API, you need to store username and password crendetials.

    Since this is premium service and you are creating open source software, naturally you cannot hardcode your login credentials to the source code itself.

    So I ended up using environment variables - work quite well:

    Here is the example:

    https://github.com/miohtama/mfabrik.zoho/blob/master/mfabrik/zoho/tests.py

    As a bigger problem I think trying to enforce unit tests module to do something it was not supposed to do in the first place is not a good idea. Maybe you should try to write your own unit test runner which would do necessary preparements (pulling info, storing results) somewhere.

    0 讨论(0)
提交回复
热议问题