That did trick -- thanks!
A few clarifications:
1) i do want "assert x + x == addit(x,y)" because I want it to generate
errors (when x is 3 and y is 3, then the assert is true; but tests will be
false in 4 out of 5 cases).
Thanks for the tip about assert:
assert x + x == addit(x,y),'expected %s, got %s' % (x+x,addit(x,y))
I did not know assert had that option!
2) in bash, nosetests does not raise an error (see below -- I'm talking
about an error in nosetests not the failed tests in nosetest.py!) when run,
nor with g.execute_shell_commands, but with sh it does:
sh=g.importExtension("sh")
g.es(sh.nosetests("nosetest.py"))
The only drawback with g.execute_shell_commands is that I don't get the
output back into Leo. :(
3) the command is in fact : command = r'nosetests
<path-to-nosetest>/nosetest.py'
4) I run Leo from byobu and typically with the --ipython option... so, you
can imagine that output gets tangled at times. But I do try to test things
without those options.
Thanks for the suggestions -- I have been using sh rather than
g.execute_shell_commands,
but the latter is clearly better in some contexts.
Best,
Bill
bill@bill-laptop:~/Soft/hack/Python$ cat nosetest.py
import nose
def addit(x,y):
return x+y
def test_addit():
for i in range(0, 5):
yield check_it, i, 3
def check_it(x,y):
assert x + x == addit(x,y)
bill@bill-laptop:~/Soft/hack/Python$ nosetests nosetest.py
FFF.F
======================================================================
FAIL: nosetest.test_addit(0, 3)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in
runTest
self.test(*self.arg)
File "/data2/Soft/hack/Python/InteractivePyCourse/nosetest.py", line 9,
in check_it
assert x + x == addit(x,y)
AssertionError
======================================================================
FAIL: nosetest.test_addit(1, 3)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in
runTest
self.test(*self.arg)
File "/data2/Soft/hack/Python/InteractivePyCourse/nosetest.py", line 9,
in check_it
assert x + x == addit(x,y)
AssertionError
======================================================================
FAIL: nosetest.test_addit(2, 3)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in
runTest
self.test(*self.arg)
File "/data2/Soft/hack/Python/InteractivePyCourse/nosetest.py", line 9,
in check_it
assert x + x == addit(x,y)
AssertionError
======================================================================
FAIL: nosetest.test_addit(4, 3)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in
runTest
self.test(*self.arg)
File "/data2/Soft/hack/Python/InteractivePyCourse/nosetest.py", line 9,
in check_it
assert x + x == addit(x,y)
AssertionError
----------------------------------------------------------------------
Ran 5 tests in 0.023s
FAILED (failures=4)
Le vendredi 1 novembre 2013 07:18:48 UTC-7, Edward K. Ream a écrit :
>
> On Mon, Oct 21, 2013 at 11:06 PM, wgw <[email protected] <javascript:>>wrote:
>
>> I am trying to get nose working in leo. Has anyone else had success?
>>
>
> Not much myself so far. However,
>
>
>
>
> def check_it(x,y):
> assert x + x == addit(x,y)
>
> is wrong. The assert should be:
>
> assert x + y == addit(x,y)
>
> Even better would be:
>
> assert x + y == addit(x,y),'expeced %s, got %s' % (x+y,addit(x,y))
>
> Also, I suggest you run this script nose from a console, or with something
> like this Leo script::
>
> import nose
> command = r'python <path-to-nosetest>/nosetest.py'
> g.execute_shell_commands(command,trace=True)
>
> HTH.
>
> Edward
>
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.