Resolve deprecation warnings
authorTom Morris <tfmorris@veritasgenetics.com>
Thu, 14 Mar 2019 22:47:20 +0000 (18:47 -0400)
committerTom Morris <tfmorris@veritasgenetics.com>
Thu, 21 Mar 2019 19:42:49 +0000 (15:42 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Morris <tfmorris@veritasgenetics.com>

tools/crunchstat-summary/crunchstat_summary/webchart.py
tools/crunchstat-summary/tests/test_examples.py

index 91a196ffbe660b4c9c5da0962896472ea319e76f..cf0c1e67aa1ffdcf7853b2b1271bb2f03b16bae2 100644 (file)
@@ -2,7 +2,11 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
 #
 # SPDX-License-Identifier: AGPL-3.0
 
-import cgi
+try:
+    from html import escape
+except ImportError:
+    from cgi import escape
+
 import json
 import pkg_resources
 
 import json
 import pkg_resources
 
@@ -27,7 +31,7 @@ class WebChart(object):
         <script type="text/javascript">{}</script>
         {}
         </head><body></body></html>
         <script type="text/javascript">{}</script>
         {}
         </head><body></body></html>
-        '''.format(cgi.escape(self.label),
+        '''.format(escape(self.label),
                    self.JSLIB, self.js(), self.headHTML())
 
     def js(self):
                    self.JSLIB, self.js(), self.headHTML())
 
     def js(self):
index 0e3ccd35a43b41a82f3f592417fac0f6f008126c..7603ea488c37e4a74f7946d3e108116329b0bad2 100644 (file)
@@ -11,6 +11,7 @@ import gzip
 from io import open
 import mock
 import os
 from io import open
 import mock
 import os
+import sys
 import unittest
 
 from crunchstat_summary.command import UTF8Decode
 import unittest
 
 from crunchstat_summary.command import UTF8Decode
@@ -53,7 +54,11 @@ class HTMLFromFile(ReportDiff):
                 ['--format=html', '--log-file', logfile])
             cmd = crunchstat_summary.command.Command(args)
             cmd.run()
                 ['--format=html', '--log-file', logfile])
             cmd = crunchstat_summary.command.Command(args)
             cmd.run()
-            self.assertRegexpMatches(cmd.report(), r'(?is)<html>.*</html>\s*$')
+            if sys.version_info >= (3,2):
+                self.assertRegex(cmd.report(), r'(?is)<html>.*</html>\s*$')
+            else:
+                self.assertRegexpMatches(cmd.report(), r'(?is)<html>.*</html>\s*$')
+
 
 class SummarizeEdgeCases(unittest.TestCase):
     def test_error_messages(self):
 
 class SummarizeEdgeCases(unittest.TestCase):
     def test_error_messages(self):