Unittest module in pyunit standard library is used to run regression tests. Unittest has a main function that check current source file for all class deri)ed from 3est)ase and runs all methods starting!ith test in it.
Unittest module in pyunit standard library is used to run regression tests. Unittest has a main function that check current source file for all class deri)ed from 3est)ase and runs all methods starting!ith test in it.
Unittest module in pyunit standard library is used to run regression tests. Unittest has a main function that check current source file for all class deri)ed from 3est)ase and runs all methods starting!ith test in it.
One &real' test function def runtest(self, name, arguments): outfile = join("out", name) goldfile = join("gold", name) # Run program if system("echo %s > %s 2>!" % " (" "#join(arguments), outfile)) $= %: self#fail("non&'ero (alue return") # )hec* output if differ(outfile, goldfile): self#fail("output for %s differs" % name)
Adding a Test def add+test(name, arguments): ,,,-dd a test "name" .ith "arguments" /ote: "name" must 0e 1ualified 2ython (aria0le name ,,, def t(self): self#runtest(name, arguments) t#func+doc = "3esting %s" % name setattr(3est4cho, "test+%s" % name, t)
Adding All Tests for test in glo0(join("gold", "5")): # 6nly files are tests if not isfile(test): continue test = 0asename(test) add+test(test, 7test8)
Running
unittest has a main function that check
current source file for all class deri)ed from 3est)ase and runs all methods starting !ith test in it # 9ain if ++name++ == "++main++": main() # :mported from unittest