From cef0b48993820349947d1963bff7fea388f6ecdb Mon Sep 17 00:00:00 2001 From: Mathieu Couette <12388398+MathieuCouette@users.noreply.github.com> Date: Fri, 9 Oct 2020 04:36:57 -0400 Subject: [PATCH] tests: Add unittest aliases to Python 2.7 --- tests/test_cli.py | 5 +++++ tests/test_config.py | 9 +++++++++ tests/test_module.py | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index b243b93..0a4e01c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -71,6 +71,11 @@ class CommandLineTestCase(unittest.TestCase): def setUpClass(cls): super(CommandLineTestCase, cls).setUpClass() + # https://docs.python.org/3/library/unittest.html#deprecated-aliases + if sys.version_info < (3, 2): + cls.assertRegex = cls.assertRegexpMatches + cls.assertRaisesRegex = cls.assertRaisesRegexp + cls.wd = build_temp_workspace({ # .yaml file at root 'a.yaml': '---\n' diff --git a/tests/test_config.py b/tests/test_config.py index 01ca5af..5e33e4b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -31,6 +31,15 @@ from yamllint import config class SimpleConfigTestCase(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(SimpleConfigTestCase, cls).setUpClass() + + # https://docs.python.org/3/library/unittest.html#deprecated-aliases + if sys.version_info < (3, 2): + cls.assertRegex = cls.assertRegexpMatches + cls.assertRaisesRegex = cls.assertRaisesRegexp + def test_parse_config(self): new = config.YamlLintConfig('rules:\n' ' colons:\n' diff --git a/tests/test_module.py b/tests/test_module.py index 570992d..b72e767 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -26,6 +26,15 @@ PYTHON = sys.executable or 'python' class ModuleTestCase(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(ModuleTestCase, cls).setUpClass() + + # https://docs.python.org/3/library/unittest.html#deprecated-aliases + if sys.version_info < (3, 2): + cls.assertRegex = cls.assertRegexpMatches + cls.assertRaisesRegex = cls.assertRaisesRegexp + def setUp(self): self.wd = tempfile.mkdtemp(prefix='yamllint-tests-')