Issue with @test node

0 views
Skip to first unread message

zpcspm

unread,
Jan 22, 2010, 12:18:01 PM1/22/10
to leo-editor
I'm trying to write a simple test that I'm running by selecting it and
then typing 'run-unit-tests-locally'.

Here is the @test node body:

--- cut here ---
root = p.copy()
while p.hasChildren():
p.firstChild().doDelete(newNode = None)

try:
p1 = p.insertAsLastChild()
body = 'foo'
p1.setBodyString(body)
c.selectPosition(p1)
c.copyOutline()
c.pasteOutline()
finally:
c.redraw_now()
--- cut here ---

My problem: the node that is being created by c.pasteOutline() has an
empty body. If after running the test I type 'paste-node' in the
minibuffer, a new node appears, it has 'foo' in the body.

Searching for "copyOutline" and "pasteOutline" in leo's html docs
doesn't provide any usage examples, so I'm stuck.

Edward K. Ream

unread,
Jan 22, 2010, 2:08:35 PM1/22/10
to leo-e...@googlegroups.com
On Fri, Jan 22, 2010 at 11:18 AM, zpcspm <zpc...@gmail.com> wrote:
> I'm trying to write a simple test that I'm running by selecting it and
> then typing 'run-unit-tests-locally'.

Did you notice that the code works when run with the execute-script
command? That indicates that something strange is going on related to
unit testing.

To make things easier to see, I added a call to p1.expand() after the line:
p1 = p.insertAsLastChild()

There is no reason at all to get stuck :-) Just insert a call to
g.pdb() in pasteOutline(). Compare what happens when run with ctrl-b
vs. run-unit-tests-locally. You will see that in the latter case
readSaxFile misses the body text.

So it looks like a bug which I'll fix soon.

Edward

zpcspm

unread,
Jan 22, 2010, 3:00:45 PM1/22/10
to leo-editor

Ok. Feel free to complete my example test with a couple of asserts
that compare the headlines and bodies of these two created children of
root and add it to the leo unit tests. Since you cleared the things up
and this seems to be a leo bug rather than me doing something wrong,
it'll be good to have a simple regression test for this.

Reply all
Reply to author
Forward
0 new messages