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

亡梦爱人 提交于 2019-12-01 05:57:15

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!