By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,587 Members | 1,580 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,587 IT Pros & Developers. It's quick & easy.

Unit tests in Leo

P: n/a
I'm quite (or very) new to both unit testing and Leo. I've
been trying to get @test nodes to work without success so
I'd like to have very simple example.

So, if I have a @file with the following content...

def divide_by_two(x):
return x/2

....and I'd like to write a @test node that checks whether
the function returns the right number ( like
assertsEqual(divide_by_two(8), 4) ). Now, what should the
@test node look like?

--
"Nowhere in me is the presence of god
Nor do I need him or want him around"

Deicide - Standing in the Flames

---
If you wish to send me an e-mail, remove .NO_SPAM and
..invalid from the address.
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello Tomi,

I'm not really sure about your question, but concerning unit testing
you can do a simple test.

import unittest

First: in your module (where you define functions) you should create a
class which use unittest.TestCase as your superclass.

Second: Use method runTest to type your test

Third: below the __name__ == "__main__" type unittest.main();

For example:
class testMyFunc(unittest.TestCase):
def runTest(self):
h = myFunc()
self.assertEqual(something,h)
#----------------------
if __name__ == "__main__":
unittest.main();
Sincerely Yours,
Pujo

Jul 18 '05 #2

P: n/a
aj****@gmail.com wrote:
Hello Tomi,

I'm not really sure about your question, but concerning unit testing
you can do a simple test.


No problem. I found the Leo forums at Source Forge and I've
already received some answers in there. Thanks for replying
though.

--
"Nowhere in me is the presence of god
Nor do I need him or want him around"

Deicide - Standing in the Flames

---
If you wish to send me an e-mail, remove .NO_SPAM and
..invalid from the address.
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.