I'm working on creating tests for the first time using the unittest package in Python. The part of the project I'm writing tests for now is a creation of a new database file (SQLite) and ensuring the various tables were set up properly. I have three tables that will have the same structure, so the tests are identical except for the table names.
Because it's so similar, I was trying to think in terms of the DRY method, and wanting to make one test function that could be used across the three tables with a parameter providing the table name of the table I want to test, then just calling the test three times, once with each table name. Something like the following:
def NameExists(self, table_name):
self.assertEqual('Name', self.db.models[table_name].record(0).value('Field Name'))
What I'm struggling with is that it appears unittest doesn't allow for parameters. Nothing I'm finding shows that parameters are supported for unittest in any way, shape, or form. I'm trying to figure out, aside from copy/pasting repetitive code, whether or not there is an intended/common way to create reusable test code with unittest.
Any thoughts/ideas would be greatly appreciated. Thanks in advance!!