[Twisted-Python] TestCase methods names

Facundo Batista facundobatista at gmail.com
Tue Mar 15 10:57:37 EDT 2011


Hello!

The TestCase class, historically, provided several ways to do the same
(I guess because we inherited the semantics from Java).

For example, to check equality, In Python2 we have:

 * assertEquals
 * assertEqual
 * failUnlessEqual

However, note that "assertEquals" was never documented (not in
Python's TestCase, neither in Trial's one).

In Python 3, the "There should be one-- and preferably only one
--obvious way to do it" rule was applied, and now the preferred way to
do that is:

  * assertEqual

Furthermore, assertEquals and failUnlessEqual are *deprecated* in Python 3:

>>> unittest.TestCase.assertEquals
<function deprecated_func at 0xb73795ec>
>>> unittest.TestCase.failUnlessEqual
<function deprecated_func at 0xb73795ec>

(I'm showing examples here using assertEqual, but the same happens for
all the functionalities there)

So, I propose to stick to the same method names than Python; this way
we'll be more consistent and easy to learn than keep providing all
variants.

In concrete, I say that we should:

- Deprecate those names that are deprecated in Python 3 (I mean, still
provide the functionality, but with a DeprecationWarning)

- Stop using them in internal code.

- Fix documentation to explain all this and show the chosen methods.

What do you think?

Regards,

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/



More information about the Twisted-Python mailing list