unittest behaving oddly
David Vincent
d__ at mac.com
Tue Jun 20 08:48:53 EDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hello
I'm hoping to get some insight into a situation that seems odd to me.
My Python experience is limited; I've just started using the unittest
module. I've had some experience with unit test support in other
languages.
Two computers that I use are similarly configured; each has Python 2.3
installed as distributed with the operating system, as far as I can
tell. The operating system is Mac OS X 10.3.9 in each case. The
hardware differs; they are both PowerPC computers. On these machines
unittest is behaving oddly, both in the same way.
If I copy the example from the unittest documentation and feed it to
Python, I get errors about methods in unittest. I think the example is
intended to pass its tests, but on my machines the code in the example
is not locating methods from unittest properly.
I've done some simple things, like inspecting the unittest code in the
library; it seems to make sense. For instance, the 'assertEquals'
method is defined as a member of TestCase.
What could be going wrong? I wonder if I should try to track down
problems in the example, or in the Python library installation on these
machines, or somewhere else.
Below is a transcript illustrating the problem.
Regards
David
PS: transcript illustrating the problem
> Mina:~/Documents/source/unittest-debug dvincent$ cat example.py
> # unittest example from documentation
>
> import unittest
>
> class IntegerArithmenticTestCase(unittest.TestCase):
> def testAdd(self): ## test method names begin 'test*'
> assertEquals((1 + 2), 3)
> assertEquals(0 + 1, 1)
> def testMultiply(self):
> assertEquals((0 * 10), 0)
> assertEquals((5 * 8), 40)
>
> if __name__ == '__main__':
> unittest.main()
>
> Mina:~/Documents/source/unittest-debug dvincent$ python example.py
> EE
> ======================================================================
> ERROR: testAdd (__main__.IntegerArithmenticTestCase)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "example.py", line 7, in testAdd
> assertEquals((1 + 2), 3)
> NameError: global name 'assertEquals' is not defined
>
> ======================================================================
> ERROR: testMultiply (__main__.IntegerArithmenticTestCase)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "example.py", line 10, in testMultiply
> assertEquals((0 * 10), 0)
> NameError: global name 'assertEquals' is not defined
>
> ----------------------------------------------------------------------
> Ran 2 tests in 0.045s
>
> FAILED (errors=2)
> Mina:~/Documents/source/unittest-debug dvincent$ python -V
> Python 2.3
> Mina:~/Documents/source/unittest-debug dvincent$
- --
David A Vincent dvincent at toshiba-tap.com
Software Engineer telephone +61 2 9850-2593
RESEARCH AND DEVELOPMENT TOSHIBA (AUSTRALIA) PTY. LIMITED
"The situation is hopeless, we must take the next step." P.Casals
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)
iQCVAwUBRJfutpjExRNGDpoZAQFb/QP9H360XupArE3NuLZvI3PPpPIs2Ht9JcLw
P7hY1iz9Bl7A/7RBNVjJeegYByJwHX+8Zlgb/uBXMlTyS8KiCsILOgeT3v+ycaZg
W7VKcY4lCm1FZJRJkGvvwKtySTb54uuLoGU6kPEqrBS0vHxbhNrKacT4vNZN9UM4
NNBttvVDijk=
=1l9n
-----END PGP SIGNATURE-----
More information about the Python-list
mailing list