kanchy kang wrote: > many people write test cases with python scripts. > in these test scripts, there are many validation statements, > for example, in unittest, failUnless(a == b),(a/b may be stringType or > intType...) > > during running test scripts, if there is one exception raised from > failUnless, i still do not know a =?, b= ?... i have to add one statment > "print a" or "print b" again... > > as i know, there are many validation statements if using python as one > test tool... > i think my suggestion or requirement may benefit users greatly... >
you could use the py.test testing framework (http://codespeak.net/py/current/doc/test.html), which tries to print useful information if a test fails. So if your test contains assert a == b and this is False, it will print the values of a and b. For example the test def test_fail(): a = 1 b = 2 assert a == b would result in the following failure: def test_fail(): a = 1 b = 2 E assert a == b > assert 1 == 2 This has the drawback that your expressions need to be side-effect free (because they will be re-evaluated) but it is quite useful. Cheers, Carl Friedrich Bolz -- http://mail.python.org/mailman/listinfo/python-list