What I would like to do is create a folder where people can put the file for testing, and automatically use pyunit to run the test as a separate test. I am currently doing the following:
class TestName(unittest.testcase):
def setUp(self):
for file in os.listdir(DIRECTORY):
def test_comparison(self):
for file in os.listdir(DIRECTORY):
def suite():
return unittest.TestSuite([
unittest.TestLoader().loadTestsFromTestCase(TestName),
])
if __name__ == "__main__":
unittest.TextTestRunner(verbosity=2).run(suite())
Obviously, there are many problems associated with this, for example, if a test fails, everything fails, etc. etc. What I would like to do is configure the pin to run the test (or test case) for each file that is placed in the directory. Now, I think what I can do is create the class mentioned above with only two methods, but in order to do this successfully, I would have to add a context parameter, for example:
def setUp(self, filepath):
Then I could put the loop in the main body of the code and run the tests as follows:
def suite():
return unittest.TestSuite([
unittest.TestLoader().loadTestsFromTestCase(TestName, file),
])
if __name__ == "__main__":
for file in DIRECTORY:
unittest.TextTestRunner(verbosity=2).run(suite(file))
, , unittest.TestCase(). , / , ? .