Which Is The Better Way To Pass Data Into Python Unittest Redirected Stdin Or Pickle?
Short Question What is the best way to get data into a Python unittest case ? Background My project is using Python's unittest module as an automated way execute a series of tests
Solution 1:
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.
Post a Comment for "Which Is The Better Way To Pass Data Into Python Unittest Redirected Stdin Or Pickle?"