SonarPython: False-positive on built-in unittest 'setUpModule' and 'tearDownModule'

Python’s built-in ‘unittest’ framework predates PEP-8 so the naming conventions don’t conform to snake_case naming conventions (python:S1542)

It looks like exceptions to the rule already exist for:

  • setUp()
  • tearDown()
  • setUpClass()
  • tearDownClass()

Code smell false positives (python:S1542) occur for the following:

  • setUpModule()
  • tearDownModule()

Code Sample:

def setUpModule():
    # code that runs before the test suites load


def tearDownModule():
    # code that runs after all of the test suites complete

Official documentation for setUpModule() & tearDownModule():
https://docs.python.org/3/library/unittest.html#setupmodule-and-teardownmodule

SQ Version: Developer Edition 9.3 (build 51899)

Hi @evanplaice ,
Welcome to our community and thanks for reporting this false positive.
I create ticket SONARPY-987 to keep track of it.
We should provide a fix for next SonarQube version.

Thanks,
Andrea

Awesome! Thank you very much :smiley:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.