Why are unittest2 methods camelCase if names_with_underscores are preferred?
Asked Answered
T

1

36

Here's the section of PEP8 that describes how function names should be:

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

mixedCase is allowed only in contexts where that's already the prevailing style

Why didn't they change the function names? This is especially relevant for Python 3 where backwards compatibility was not maintained.

Trickster answered 9/6, 2013 at 22:25 Comment(0)
S
21

From unittest2 website:

unittest2 is a backport of the new features added to the unittest testing framework in Python 2.7. It is tested to run on Python 2.4 - 2.7.

To use unittest2 instead of unittest simply replace import unittest with import unittest2.

Its a bit confusing as from a version 2 is not expected to be a backport, but a new major release with (probably) new features. Anyway, the main idea is creating a backport where all the user has to do is changing the import statement. For this they could not change their method signatures

Also, from unittest website:

The Python unit testing framework, sometimes referred to as “PyUnit,” is a Python language version of JUnit, by Kent Beck and Erich Gamma. JUnit is, in turn, a Java version of Kent’s Smalltalk testing framework. Each is the de facto standard unit testing framework for its respective language.

So this explains the whole resemblance between the frameworks and probably the camel case notation

Shirley answered 9/6, 2013 at 22:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.