File: HACKING.rst

package info (click to toggle)
python-shade 1.30.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,172 kB
  • sloc: python: 33,348; sh: 111; makefile: 17
file content (49 lines) | stat: -rw-r--r-- 1,425 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
shade Style Commandments
========================

Read the OpenStack Style Commandments
https://docs.openstack.org/hacking/latest/

Indentation
-----------

PEP-8 allows for 'visual' indentation. Do not use it. Visual indentation looks
like this:

.. code-block:: python

  return_value = self.some_method(arg1, arg1,
                                  arg3, arg4)

Visual indentation makes refactoring the code base unneccesarily hard.

Instead of visual indentation, use this:

.. code-block:: python

  return_value = self.some_method(
      arg1, arg1, arg3, arg4)

That way, if some_method ever needs to be renamed, the only line that needs
to be touched is the line with some_method. Additionaly, if you need to
line break at the top of a block, please indent the continuation line
an additional 4 spaces, like this:

.. code-block:: python

  for val in self.some_method(
          arg1, arg1, arg3, arg4):
      self.do_something_awesome()

Neither of these are 'mandated' by PEP-8. However, they are prevailing styles
within this code base.

Unit Tests
----------

Unit tests should be virtually instant. If a unit test takes more than 1 second
to run, it is a bad unit test. Honestly, 1 second is too slow.

All unit test classes should subclass `shade.tests.unit.base.BaseTestCase`. The
base TestCase class takes care of properly creating `OpenStackCloud` objects
in a way that protects against local environment.