Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django TestCase class - why are some methods camel case and others snake case?

Tags:

django

https://docs.djangoproject.com/en/2.1/_modules/django/test/testcases/#TestCase.setUpTestData

As far as I know, the convention is to use snake case for method names, so why do we see some methods in camel case in Python?

like image 920
as8 Avatar asked Feb 23 '19 10:02

as8


People also ask

Should I use CamelCase or snake case?

Camel case (ex: camelCase) is usually for variables, properties, attributes, methods, and functions. Snake case (ex: snake_case) is commonly used in scripting languages like Python and as a constant in other C-styled languages. Pascal case (ex: PascalCase) is mainly reserved for class names, interfaces, and namespaces.

Why would you use camel case instead of snake case?

When multiple words are used to form a variable, camel case joins those words together, without any white space, and delineates the start of each new word with a capital letter. In contrast, snake case uses an underscore between words to create separation.

When should CamelCase be used?

When a computer parses text, it treats the spaces as a delimiter between words. CamelCase is most used in places where white space is not allowed for technical reasons. This can make the phrase hard to read or ambiguous.

Is Python snake case or CamelCase?

Python, by contrast, recommends snake case, whereby words are instead separated by underscores ( _ ), with all letters in lowercase.


1 Answers

Django's test framework inherits from Python's unittest module. That in turn is heavily based on the Java jUnit framework. Java uses camel case naming conventions; when the code was ported to Python the names were kept.

like image 174
Daniel Roseman Avatar answered Sep 30 '22 04:09

Daniel Roseman