Hi all, Chris was complaining that it was difficult to instantiate and run a single test with the current test framework, because with unittest-based tests you can't just import the test module & run a single test.
Attached is a simple script, 'run_single.py', that uses the unittest test loader to accomplish this; try: % python run_single.py seqdb_test.SequenceFileDB_Test There's also a simple programmatic interface: >>> import seqdb_test >>> from run_single import run_test >>> run_test('SequenceFileDB_Test', seqdb_test) I think it might be worth adding this behavior directly to runtest.py with a simple command-line option; any thoughts? cheers, --titus -- C. Titus Brown, c...@msu.edu --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pygr-dev" group. To post to this group, send email to pygr-dev@googlegroups.com To unsubscribe from this group, send email to pygr-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pygr-dev?hl=en -~----------~----~----~----~------~----~------~--~---
""" Usage: >>> import seqdb_test >>> from run_single import run_test >>> run_test('SequenceFileDB_Test', seqdb_test) OR % python run_single.py seqdb_test.SequenceFileDB_Test Note, run_single.py must be in the same directory as the test file being imported. """ import sys import unittest import testlib def run_test(name, module=None, verbosity=2): l = unittest.TestLoader() suite = l.loadTestsFromName(name, module) runner = unittest.TextTestRunner(verbosity=verbosity, descriptions=0) runner.run(suite) if __name__ == '__main__': run_test(sys.argv[1])