Re-running unittest

  • Thread starter =?ISO-8859-1?Q?Israel_Fern=E1ndez_Cabrera?=
  • Start date
?

=?ISO-8859-1?Q?Israel_Fern=E1ndez_Cabrera?=

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.PruebasDePrueba")
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
(e-mail address removed)

. 0 .
. . 0
0 0 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top