[Twisted-Python] TestCase methods names

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Fri Mar 18 19:36:55 MDT 2011


On 15 Mar, 02:57 pm, facundobatista at gmail.com wrote:
>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?

+1 from me.

Jean-Paul




More information about the Twisted-Python mailing list