Re: [Pyunit-interest] feature and usage questions.
Brought to you by:
purcell
From: Shae E. <sh...@ua...> - 2000-05-18 00:42:11
|
Stephen Purcell wrote: > > Shae Erisson wrote: > > > > Yay PyUnit! It's easy to use and it helps me find bugs! > > > > It's not perfect though :) > > Admit it, you'd be disappointed if it was. :-) I agree. I would! > Run: 1 Failures: 0 Errors: 1 > There was 1 error: > 1) __main__.MyTestCase.checkSomething > Traceback (innermost last): > File "<stdin>", line 3, in checkSomething > NameError: oops yes, this was my problem, I corrected it by downloading the latest version of PyUnit (oops). > import test_ast, test_brm, unittest > alltests = unittest.TestSuite() > alltests.addSuite(test_ast.suite()) > alltests.addSuite(test_brm.suite()) The latest downloadable version of PyUnit doesn't have an addSuite. Ah, upon further reading of this email, alltests.addTest(test_ast.suite()) _does_ work. This is exactly what I wanted. > > As for Tk GUI support, what about sticking support for PyUnit into IDLE? > > That's a thoroughly excellent idea. > > Haven't got my head enough into (inter?) Tk to offer my services at this > point. I'd like to get a good clone of the basic JUnit GUI, but if it > could be used with IDLE as well as standalone, that would be wonderful. > I started on a GUITestRunner, but didn't get far. One nice feature of > JUnit is that all classes are reloaded automatically between test runs, > so the GUI need not be restarted constantly. Think it might be more > fiddly with Python (hard to believe, but that's my suspicion). Here's the process I came up with(after some discussion on IRC): make sure you run tearDown, then: def getImportedModules(mod): return filter(lambda (x,y): type(y) is types.ModuleType, vars(mod).items()) for module in getImportedModules(modname): reload(module) This would only work if you knew the name of module that had the tests defined in it though, and if no import x from y lines were in it. I don't know how a GUITestRunner would know which module it was started from, though I may be missing something obvious. The only solution I can think of to the above two problems is loading the test definitions from a dialog or something, not calling the GUI from the tests file. It is quite fiddly though :( -- sHae mAtijs eRisson (sH...@wE...) gEnius fOr hIre bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt 13:00pm up 1 season, 1 squirrel, load average: 1+1j 0.5+2j 0.2+0.5j |