unittest and automatically firing off tests
Tom Plunket
tomas at fancy.org
Sat Jun 21 14:32:33 EDT 2003
Bernhard Herzog wrote:
> I think it's done that way to set the return code of the python process
> so that in a shell you could use it to determine whether the tests were
> executed successfully.
Oh- I hadn't though about that. Makes sense.
> files = os.listdir(os.curdir)
> names = []
> for file in files:
> if file[:4] == "test" and file[-3:] == ".py":
> names.append(file[:-3])
>
> suite = unittest.defaultTestLoader.loadTestsFromNames(names)
> runner = unittest.TextTestRunner(verbosity = 2)
> result = runner.run(suite)
>
> sys.exit(not result.wasSuccessful())
Super, will extract what I can from this. Thanks.
-tom!
More information about the Python-list
mailing list