Open
Description
If aliasing unittest.skip
with a value and inadvertently trying to pass an argument to the aliased copy, pytest will skip the entire module while unittest
will throw an error.
import unittest
broken = unittest.skip("broken")
class MyTests(unittest.TestCase):
@broken
def test_good(self):
assert False
@broken("bar")
def test_evil(self):
assert False
pytest output
=============================================== test session starts ===============================================
platform darwin -- Python 3.11.2, pytest-7.2.2, pluggy-1.0.0
rootdir: ...
collected 0 items / 1 skipped
=============================================== 1 skipped in 0.01s ================================================
While running the same module via python -m unittest
throws a unittest.case.SkipTest: broken
error and fails loudly.
While the pattern of using the alias with a standard reason isn't a great pattern itself, nonetheless the behavior when it's used incorrectly is unprotected and easy to miss when you are trying to stable a test suite.