471,334 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 software developers and data experts.

Re-running unittest

Hi
I'm writing some code that automatically execute some registered unit
test in a way to automate the process. A sample code follows to
illustrate what I'm doing:

<code requires="save as import_tests.py">
class PruebasDePrueba(unittest.TestCase):
def testUnTest(self):
a = 2
b = 1
self.assertEquals(a, b)

def runTests():
loader = unittest.TestLoader()
result = unittest.TestResult()
suite = loader.loadTestsFromName("import_tests.PruebasDePr ueba")
suite.run(result)
print "Errores: ", len(result.errors)
print "Fallos: ", len(result.failures)

if __name__ == "__main__":
runTests()
raw_input("Modify [fix] the test and press ENTER to continue")
</code>

The code executes the tests from the class PruebasDePrueba, as the
user to "fix" the failing test and then executes the tests again after
ENTER is pressed.
The test's initial state is "fail" so, equaling the values of a or b
in the second execution I wait the test does not fails again, but it
does.
I've changed the original code in very different ways trying to figure
out what is wrong with it but no success
The problem is not reproduced if instead of loading the test from the
TestCase (import_tests.PruebasDePrueba) they are loaded referring the
container module and this behaves like this because I wrote a class
that inherits from unittest.TestLoader abd re-defines the
loadTestsFromModule(module) then every time this method is called, the
module is reloaded via "reload" python's function. I would like to do
the same with TestCases.

I have written this problem to several other python lists but I have
not received any answer, hope this time is different,
I'd like to thaks in advance, regards
--
____________________
Israel Fdez. Cabrera
if****@gmail.com

. 0 .
. . 0
0 0 0
Jul 22 '07 #1
0 888

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Nel | last post: by
4 posts views Thread by Craig Bailey | last post: by
1 post views Thread by Chris | last post: by
11 posts views Thread by James | last post: by
1 post views Thread by John Ryan | last post: by
10 posts views Thread by James | last post: by
8 posts views Thread by Beowulf | last post: by
3 posts views Thread by presspley | last post: by
2 posts views Thread by sky2070 | last post: by
1 post views Thread by Brian | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.