Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

53 lines
1.4 KiB
Plaintext

== 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
[source,python]
----
import unittest
class MyTest(unittest.TestCase):
def setUp(self): ... # OK (unittest.TestCase method)
def something_test(self): ... # Noncompliant
----
=== Compliant solution
[source,python]
----
import unittest
class MyTest(unittest.TestCase):
def setUp(self): ...
def test_something(self): ...
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Rename this method so that it starts with "test" or remove this unused helper.
=== Highlighting
Primary: the name of the method.
endif::env-github,rspecator-view[]