File sitecustomize.py of Package failed_python-cpplint

# Compat shims loaded early in test runs to provide old unittest API that some
# legacy tests (and upstream code) expect (like assert_ and assertEquals).
#
# Placing this as sitecustomize.py in the project root ensures Python's site
# machinery will import it early (current working directory is on sys.path for
# test runs), so it can patch unittest.TestCase before the tests are executed.
#
# Keep this file minimal: only add missing aliases if they don't already exist.

import unittest

# Provide assert_ (old name) -> assertTrue
if not hasattr(unittest.TestCase, "assert_"):
    def _assert_(self, expr, msg=None):
        # Use the modern assertTrue implementation
        return self.assertTrue(expr, msg)
    unittest.TestCase.assert_ = _assert_

# Provide assertEquals (deprecated/removed alias) -> assertEqual
if not hasattr(unittest.TestCase, "assertEquals"):
    # assign the existing assertEqual method as alias
    unittest.TestCase.assertEquals = unittest.TestCase.assertEqual

# Some code might call assertEquals with 2 or 3 args; using the alias above
# preserves argument semantics handled by assertEqual.

# End of shim.
openSUSE Build Service is sponsored by