Bug 1471625 - Resolve Python 3.5 compat issues in mozinfo;r?davehunt draft
authorRaphael Pierzina <rpierzina@mozilla.com>
Tue, 03 Jul 2018 11:06:11 +0200
changeset 813494 6f9a9b6d25fc8ba5440ea204384bdec01cd79c35
parent 813360 7d20e7fae1039720f92db1a3a72bc2c7424b5f98
child 813602 609d7181a37bbb771cc16e1a155e5600d5d6e7f5
push id114917
push userbmo:rpierzina@mozilla.com
push dateTue, 03 Jul 2018 09:07:41 +0000
reviewersdavehunt
bugs1471625
milestone63.0a1
Bug 1471625 - Resolve Python 3.5 compat issues in mozinfo;r?davehunt MozReview-Commit-ID: HdPEVAJnXZf
testing/mozbase/mozinfo/mozinfo/string_version.py
testing/mozbase/mozinfo/tests/manifest.ini
testing/mozbase/mozinfo/tests/test.py
--- a/testing/mozbase/mozinfo/mozinfo/string_version.py
+++ b/testing/mozbase/mozinfo/mozinfo/string_version.py
@@ -8,17 +8,17 @@ from distutils.version import LooseVersi
 
 
 class StringVersion(str):
     """
     A string version that can be compared with comparison operators.
     """
 
     def __init__(self, vstring):
-        str.__init__(self, vstring)
+        super(StringVersion, self).__init__()
         self.version = LooseVersion(vstring)
 
     def __repr__(self):
         return "StringVersion ('%s')" % self
 
     def __to_version(self, other):
         if not isinstance(other, StringVersion):
             other = StringVersion(other)
--- a/testing/mozbase/mozinfo/tests/manifest.ini
+++ b/testing/mozbase/mozinfo/tests/manifest.ini
@@ -1,4 +1,3 @@
 [DEFAULT]
 subsuite = mozbase, os == "linux"
-skip-if = python == 3
 [test.py]
--- a/testing/mozbase/mozinfo/tests/test.py
+++ b/testing/mozbase/mozinfo/tests/test.py
@@ -12,16 +12,22 @@ import os
 import shutil
 import sys
 import tempfile
 import unittest
 import mozinfo
 
 import mozunit
 
+PY3 = sys.version_info[0] == 3
+
+if PY3:
+    # reload() has been moved to importlib in Python 3
+    # see https://docs.python.org/3.5/library/importlib.html#importlib.reload
+    from importlib import reload
 
 class TestMozinfo(unittest.TestCase):
 
     def setUp(self):
         reload(mozinfo)
         self.tempdir = os.path.abspath(tempfile.mkdtemp())
 
         # When running from an objdir mozinfo will use a build generated json file