octavia.hacking package

Submodules

octavia.hacking.checks module

Guidelines for writing new hacking checks

  • Use only for Octavia specific tests. OpenStack general tests should be submitted to the common ‘hacking’ module.

  • Pick numbers in the range O3xx. Find the current test with the highest allocated number and then pick the next value.

  • Keep the test method code in the source file ordered based on the O3xx value.

  • List the new rule in the top level HACKING.rst file

  • Add test cases for each new rule to octavia/tests/unit/test_hacking.py

assert_equal_in(logical_line)[source]

Check for assertEqual(A in B, True), assertEqual(True, A in B),

assertEqual(A in B, False) or assertEqual(False, A in B) sentences

O338

assert_equal_or_not_none(logical_line)[source]

Check for assertEqual(A, None) or assertEqual(None, A) sentences,

assertNotEqual(A, None) or assertNotEqual(None, A) sentences

O318

assert_equal_true_or_false(logical_line)[source]

Check for assertEqual(True, A) or assertEqual(False, A) sentences

O323

assert_true_instance(logical_line)[source]

Check for assertTrue(isinstance(a, b)) sentences

O316

check_line_continuation_no_backslash(logical_line, tokens)[source]

O346 - Don’t use backslashes for line continuation.

Parameters
  • logical_line – The logical line to check. Not actually used.

  • tokens – List of tokens to check.

Returns

None if the tokens don’t contain any issues, otherwise a tuple is yielded that contains the offending index in the logical line and a message describe the check validation failure.

check_no_eventlet_imports(logical_line)[source]

O345 - Usage of Python eventlet module not allowed.

Parameters

logical_line – The logical line to check.

Returns

None if the logical line passes the check, otherwise a tuple is yielded that contains the offending index in logical line and a message describe the check validation failure.

check_no_import_mock(logical_line)[source]

O349 - Test code must not import mock library.

Parameters

logical_line – The logical line to check.

Returns

None if the logical line passes the check, otherwise a tuple is yielded that contains the offending index in logical line and a message describe the check validation failure.

check_no_logging_imports(logical_line)[source]

O348 - Usage of Python logging module not allowed.

Parameters

logical_line – The logical line to check.

Returns

None if the logical line passes the check, otherwise a tuple is yielded that contains the offending index in logical line and a message describe the check validation failure.

check_raised_localized_exceptions(logical_line, filename)[source]

O342 - Untranslated exception message.

Parameters
  • logical_line – The logical line to check.

  • filename – The file name where the logical line exists.

Returns

None if the logical line passes the check, otherwise a tuple is yielded that contains the offending index in logical line and a message describe the check validation failure.

no_log_warn(logical_line)[source]

Disallow ‘LOG.warn(‘

O339

no_mutable_default_args(logical_line)[source]
no_translate_logs(logical_line, filename)[source]

O341 - Don’t translate logs.

Check for ‘LOG.*(_(‘ and ‘LOG.*(_Lx(‘

Translators don’t provide translations for log messages, and operators asked not to translate them.

  • This check assumes that ‘LOG’ is a logger.

Parameters
  • logical_line – The logical line to check.

  • filename – The file name where the logical line exists.

Returns

None if the logical line passes the check, otherwise a tuple is yielded that contains the offending index in logical line and a message describe the check validation failure.

revert_must_have_kwargs(logical_line)[source]

O347 - Taskflow revert methods must have **kwargs.

Parameters

logical_line – The logical line to check.

Returns

None if the logical line passes the check, otherwise a tuple is yielded that contains the offending index in logical line and a message describe the check validation failure.

Module contents