I am looking for an elegant way to run unit tests on multiple data, in this case a directory containing text files .
Consider a folder text containing several txt files, I want run this example unittest on each file ( for example by feeding a list of files from glob to my unittest )
Here is how I test a single hardcoded file .
import unittest
import parser
class TestParser(unittest.TestCase):
text_path = 'text/journal.txt'
def test_get_chapters(self):
x = parser.get_chapters(self.text_path)
self.assertGreater(len(x),1))
if __name__ = "__main__":
unittest.main()
Thanks !!