[Pulp-list] Unit Test Assertions

Jason Dobies jason.dobies at redhat.com
Fri May 28 19:10:29 UTC 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

We might want to use the unittest.TestCase assertions instead of simple
assert due to the increased readability of the output.


With just assert:

Traceback (most recent call last):
  File "/home/jdob/vault/code/pulp/test/unit/test_util.py", line 54, in
test_loadConfig
    assert(config.get('paths', 'http_mount') == '/var/lib/pulp')
AssertionError


Using self.assertEqual:

Traceback (most recent call last):
  File "/home/jdob/vault/code/pulp/test/unit/test_util.py", line 54, in
test_loadConfig
    self.assertEqual(config.get('paths', 'http_mount'), '/var/lib/pulp')
AssertionError: '/var/www/pulp' != '/var/lib/pulp'


It's a ton more readable to see the values that are being compared in
the equals rather than just the code.

- -- 
Jason Dobies
RHCE# 805008743336126
Freenode: jdob
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMABUlAAoJEOMmcTqOSQHCAAwIAKrWOCRt7FZRIsy7tuZNGOUc
z8ZVZVc+e9csL+GrGCxI3hRJ5NVIR9y10zW/3gViAhPoaWuURB8VuLtEDJmqLtkW
Dt5xwc9PNRnUkrr3Jke3N7lv+j000vu5qVH+TGtD/YJpzQWZyn+f7at4c403p3BZ
gavyPvX4oOsBfKI6wf9u6U9WBA+sC5RKYFECz9B147n/iVjr2vTJd+OGGLJTuBuM
LKThoddJ/+L/0i5eF3O4Wy4frxNHNk1gGM+IM6gAf+cY0I8VUk+gCDbFLx+iIfg4
G5CMCrE12IkjDumGKrliBaSopXfmqWqEoxhsK44glvjM6A3jD3ixNWG+45lzJh8=
=oeNp
-----END PGP SIGNATURE-----




More information about the Pulp-list mailing list