cinder/HACKING.rst
Jay S. Bryant 5347439142 Improve regex for _ import hacking check
Commit 3e2b1117 added a check to make sure that the _
function was being explicitly imported so that translation would
work properly.

I have discovered that those regexes/code would not work in some cases.
Particularly if the import line imported multiple things from
gettextutils or i18n.  Also the check being used to find lines using
the _ function was not right.

This commit fixes the issues and adds appropriate tests.  It also
adds the hacking check to HACKING.rst which should have been done the
first time around.

Change-Id: I7227bb0051836e537bff2f0f97662c06452d5af6
2014-08-07 15:55:58 -05:00

1.3 KiB

Cinder Style Commandments

Cinder Specific Commandments

  • [N319] Validate that debug level logs are not translated

- [N323] Add check for explicit import of _() to ensure proper translation. General -------- Use 'raise' instead of 'raise e' to preserve original traceback or exception being reraised:

except Exception as e:
    ...
    raise e  # BAD

except Exception:
    ...
    raise  # OKAY

Creating Unit Tests

For every new feature, unit tests should be created that both test and (implicitly) document the usage of said feature. If submitting a patch for a bug that had no unit test, a new passing unit test should be added. If a submitted bug fix does have a unit test, be sure to add a new one that fails without the patch and passes with the patch.

Cinder is transitioning to use mock, rather than mox, and so new tests should use mock only.

For more information on creating unit tests and utilizing the testing infrastructure in OpenStack Cinder, please read the Cinder testing README.rst.