How to do integration tests for a Python script?
I have a Python command line script that connects to a database, generates files from the data and sends e-mails. I already have some unit-tests for the important components. Now I'd like to do tests that use several or all components together, load the test database with sample data and check for the correct output.
Are there Python libraries that support this kind o开发者_运维问答f testing? Specifically, I'm looking for easy ways to
- put sample data in the database
- check for specific changes in the database
- check for existence and content of specific files
Should I even do these tests in Python or should I just write a bunch of shell scripts?
I use nosetests
http://somethingaboutorange.com/mrl/projects/nose/1.0.0/
And it fits very well with another component, "Coverage", that provides you with information about how much of your code is tested.
Yes. The unittest
libraries can be used for this.
Don't be fooled by the name. A "unit" is not always a single, standalone class (or function).
A "unit" can be a composite "unit" of one or more classes or modules or packages.
精彩评论