Skip to content

Commit

Permalink
test_hardware: code formating for multiline construct
Browse files Browse the repository at this point in the history
The coding style, in test cases of VCPUTopologyTest and
 NUMATopologyTest test classes from file test_hardware.py,
is inconsistent. This patch is to reformat these part of
code according to following rules:

- Arrange the `extra_specs` property in a seperate line to allow the
  extra_spec with a long name or value.

    An example:
    some code before reformating:

    "flavor": objects.Flavor(vcpus=4, memory_mb=2048,
                             extra_specs={
        "hw:cpu_max_sockets": "5",
        "hw:cpu_max_cores": "2",
        "hw:cpu_max_threads": "3",
    }),

    It will be formated as:

	"flavor": objects.Flavor(
            vcpus=4, memory_mb=2048,
            extra_specs={
                "hw:cpu_max_sockets": "5",
                "hw:cpu_max_cores": "2",
                "hw:cpu_max_threads": "3",
	    }
	)

- *Try* to put the closing brace/bracket/parenthesis on multiline
  constructs line up under the first character of the line that
  starts the multiline construct.

  example:
  a piece of code in original code
    {
        "numa_topology": objects.InstanceNUMATopology(
            cells=[
                objects.InstanceNUMACell(
                id=0, cpuset=set([0, 1, 2, 3]), memory=2048,
                cpu_topology=objects.VirtCPUTopology(
                sockets=1, cores=1, threads=4))]),
        "expect": [2, 1, 2]
    },

  after the reformating, it would be

    {
        "numa_topology": objects.InstanceNUMATopology(cells=[
            objects.InstanceNUMACell(
                id=0, cpuset=set([0, 1, 2, 3]), memory=2048,
                cpu_topology=objects.VirtCPUTopology(
                sockets=1, cores=1, threads=4)),
        ]),
        "expect": [2, 1, 2]
    },

- No space or new-line between an empty brace:

  change following code

  "image": {
  }

  to

  "image": {}

Change-Id: I81f1af98861a7f26d34348473ec245598ff856a8
Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
  • Loading branch information
huaqiangwang committed Jul 10, 2020
1 parent 9fc63c7 commit 55ff751
Showing 1 changed file with 688 additions and 540 deletions.

0 comments on commit 55ff751

Please sign in to comment.