From 9489afe68cd0d62cefa7dd3e1e6dd7b741821423 Mon Sep 17 00:00:00 2001 From: Serge Guelton Date: Thu, 3 Jan 2019 14:11:41 +0000 Subject: [PATCH] Python compat - assertRaisesRegex Python3 uses assertRaisesRegex instad of assertRaisesRegexp. Differential Revision: https://reviews.llvm.org/D56251 llvm-svn: 350308 --- bindings/python/llvm/tests/base.py | 5 +++++ bindings/python/llvm/tests/test_disassembler.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bindings/python/llvm/tests/base.py b/bindings/python/llvm/tests/base.py index 194f1a41192..aa435bc1f35 100644 --- a/bindings/python/llvm/tests/base.py +++ b/bindings/python/llvm/tests/base.py @@ -1,6 +1,8 @@ import os.path +import sys import unittest + POSSIBLE_TEST_BINARIES = [ 'libreadline.so.5', 'libreadline.so.6', @@ -15,6 +17,9 @@ POSSIBLE_TEST_BINARY_PATHS = [ ] class TestBase(unittest.TestCase): + if sys.version_info.major == 2: + assertRaisesRegex = unittest.TestCase.assertRaisesRegexp + def get_test_binary(self): """Helper to obtain a test binary for object file testing. diff --git a/bindings/python/llvm/tests/test_disassembler.py b/bindings/python/llvm/tests/test_disassembler.py index f469ffbf393..29f2f7060ba 100644 --- a/bindings/python/llvm/tests/test_disassembler.py +++ b/bindings/python/llvm/tests/test_disassembler.py @@ -19,7 +19,7 @@ class TestDisassembler(TestBase): self.assertEqual(s, '\tjcxz\t-127') def test_nonexistent_triple(self): - with self.assertRaisesRegexp(Exception, "Could not obtain disassembler for triple"): + with self.assertRaisesRegex(Exception, "Could not obtain disassembler for triple"): Disassembler("nonexistent-triple-raises") def test_get_instructions(self):