Classes subclassing unittest.TestCase are considered test cases. 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:

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): ...