rspec/rules/S1607/python/rule.adoc
2020-12-23 14:59:06 +01:00

27 lines
1.0 KiB
Plaintext

When a test fails due, for example, to infrastructure issues, you might want to ignore it temporarily. But without some kind of notation about why the test is being ignored, it may never be reactivated. Such tests are difficult to address without comprehensive knowledge of the project, and end up polluting their projects.
This rule raises an issue for each skipped test with "``unittest.skip``" or "``pytest.mark.skip``" without providing a reason argument.
== Noncompliant Code Example
----
import unittest
class MyTest(unittest.TestCase):
@unittest.skip # Noncompliant
def test_something(self): ...
----
== Compliant Solution
----
import unittest
class MyTest(unittest.TestCase):
@unittest.skip("need to fix something")
def test_something(self): ...
----
== See
https://docs.python.org/3/library/unittest.html#skipping-tests-and-expected-failures[Unittest documentation - skipping tests and expected failures]
https://docs.pytest.org/en/latest/skipping.html#skipping-test-functions[Pytest documentation - skipping test functions]