[PATCH] D85692: python bindings: fix DeprecationWarning

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 10 15:22:09 PDT 2020


nickdesaulniers created this revision.
nickdesaulniers added reviewers: MaskRay, echristo, srhines.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.
nickdesaulniers requested review of this revision.

Fixes observed warning running `ninja check-all`:
llvm-project/clang/bindings/python/tests/cindex/test_diagnostics.py:100:
DeprecationWarning: Please use assertRegex instead.

  self.assertRegexpMatches(children[0].spelling

Looks like unittest.assertRegexpMatches has been deprecated in favor of
unittest.assertRegex since Python 3.2, according to:
https://docs.python.org/3/library/unittest.html#deprecated-aliases


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85692

Files:
  clang/bindings/python/tests/cindex/test_diagnostics.py


Index: clang/bindings/python/tests/cindex/test_diagnostics.py
===================================================================
--- clang/bindings/python/tests/cindex/test_diagnostics.py
+++ clang/bindings/python/tests/cindex/test_diagnostics.py
@@ -41,7 +41,7 @@
         self.assertEqual(tu.diagnostics[0].severity, Diagnostic.Warning)
         self.assertEqual(tu.diagnostics[0].location.line, 1)
         self.assertEqual(tu.diagnostics[0].location.column, 26)
-        self.assertRegexpMatches(tu.diagnostics[0].spelling,
+        self.assertRegex(tu.diagnostics[0].spelling,
             'use of GNU old-style.*')
         self.assertEqual(len(tu.diagnostics[0].fixits), 1)
         self.assertEqual(tu.diagnostics[0].fixits[0].range.start.line, 1)
@@ -56,7 +56,7 @@
         self.assertEqual(tu.diagnostics[0].severity, Diagnostic.Warning)
         self.assertEqual(tu.diagnostics[0].location.line, 1)
         self.assertEqual(tu.diagnostics[0].location.column, 16)
-        self.assertRegexpMatches(tu.diagnostics[0].spelling,
+        self.assertRegex(tu.diagnostics[0].spelling,
             'incompatible pointer to.*')
         self.assertEqual(len(tu.diagnostics[0].fixits), 0)
         self.assertEqual(len(tu.diagnostics[0].ranges), 1)
@@ -97,7 +97,7 @@
         children = d.children
         self.assertEqual(len(children), 1)
         self.assertEqual(children[0].severity, Diagnostic.Note)
-        self.assertRegexpMatches(children[0].spelling,
+        self.assertRegex(children[0].spelling,
                 '.*declared here')
         self.assertEqual(children[0].location.line, 1)
         self.assertEqual(children[0].location.column, 6)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85692.284515.patch
Type: text/x-patch
Size: 1666 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200810/abdf8ef0/attachment.bin>


More information about the cfe-commits mailing list