Jan-21-2019, 08:26 AM
class TestSuites(unittest.TestCase): def completeTest(self): pathCSV = r'pathToCSV\testCSV.csv' with open(pathCSV, 'rb') as csvfile: reader = csv.reader(csvfile) for row in reader: for item in row: try: getattr(MyFile.myClass, item)() except AttributeError: print("Unknown attribute", item, "ignored") @staticmethod def myTests(): suite = unittest.TestSuite() suite.addTest(TestSuites('completeTest')) return suite if __name__== "__main__": runner.run(MyFile.TestSuites.myTests())I have this piece of code wich reads a CSV file and runs a test(completeTest). The CSV file looks like this:
startApp,stopApp
startApp,createNewProject,stopApp
so each line in the CSV should be a test. Now everything that comes from the CSV lies under one test in my code. I want to run a test for each line in the CSV? How can I do this?
Thank you