I have a bunch of unittests written in python in which messages (text) of any kind is used. Instead of 'hardcoding' the text examples used for the tests I would like to use a database of some kind (simple text file, pickle file) which contains such test examples, and which can be extended either manually or automatically very easily.

Is there a dedicated framework/module available, or do I do this simply on my own and create a simple text file? Maybe there are some best practices available I can follow?

1 Answer 1



You might want to look at some of the answers to this question: What are some good approaches to separating test data from test scripts?

It's not specifically aimed at unit tests, but the general principle is similar. If your unit test framework doesn't support a data source attribute or declaration, you could design your own method of using external data sources.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.