On Aug 20, 7:40 am, "Edward K. Ream" <[email protected]> wrote: > I always recommend unit tests. Especially for headlines, which are > the most fragile part of Leo. > > I doubt if there are any helpers. The place to look is in leoTest.py. > The new recommended pattern is to define common helpers in a node > near the unit test in unitTest.leo, and then to use:: > > exec(g.findTestScript(c,<headline name>) > > to "import" the common code into your unit test.
I tried to create an updated version of runEditCommandTest that would also work with headlines, and I got it to work for delete-word, but I ran into an issue. It seems that c.k.simulateCommand doesn't work in headlines. The only headline tests I saw used c.k.manufactureKeyPressForCommandName, which is what I used, but that only works if there is a keyboard binding (also, I altered it so that it makes tests fail if it can't find a binding). Do you know if there's some fundamental difference that prevents simulateCommand from working in the headline edit control, or is it something that might be fixable? Or perhaps I'm just doing something wrong (I'm not very familiar with the GUI code)? I put the updated runEditCommandTest in a node in unitTest.leo for use with g.findTestScript. Is that okay with you? Should I delete the old version from leoTest.py and change the existing uses to findTestScript (if you approve of the new version)? I wasn't sure whether to put the headline tests in the same @test node as the body tests (since they can share the before and after nodes). Would you prefer that the headline tests be separate? My current code is at 'lp:~samh/leo-editor/delete-word'. The new tests pass for the Qt GUI; I thought it was working with Tk, but apparently something is broken in the test code (the commands themselves work as far as I can tell). Side note: I noticed I was making a lot of frivolous changes to unitTest.leo, adding or removing the 'a="E"' attribute (it seems that they unnecessarily obscure the relevant parts of the diff). Is there some way to avoid doing this, or is this a good reason to use external files with the "@all" directive, like in LeoDocs.leo? Sam -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/leo-editor?hl=en.
