org.sonar.l10n.py.rules.python.S5899.html Maven / Gradle / Ivy
Why is this an issue?
Classes subclassing only unittest.TestCase
are considered test cases, otherwise they might be mixins.
As classes subclassing unittest.TestCase
will be executed as tests, they should define test methods and not be used as "abstract"
parent helper. Methods within the class will be discovered by the test runner if their name starts with test
. If a method intended to be
a test does not respect this convention, it will not be executed.
This rule raises an issue when a method is not discoverable as a test and is never used within its test case class.
This rule will not raise if:
- The method is called directly from another method.
- The method overrides an existing one in
unittest.TestCase
(example: a tearDown
method).
Noncompliant code example
import unittest
class MyTest(unittest.TestCase):
def setUp(self): ... # OK (unittest.TestCase method)
def something_test(self): ... # Noncompliant
Compliant solution
import unittest
class MyTest(unittest.TestCase):
def setUp(self): ...
def test_something(self): ...
© 2015 - 2024 Weber Informatics LLC | Privacy Policy