run-tests: work around with_hg being bytes or string depending on provenance
authorAugie Fackler <augie@google.com>
Sun, 12 Apr 2015 15:35:57 -0400
changeset 25042 201823c50610
parent 25041 09c71e3da704
child 25043 facaceeb85ac
run-tests: work around with_hg being bytes or string depending on provenance
tests/run-tests.py
--- a/tests/run-tests.py	Tue Apr 14 16:03:04 2015 -0400
+++ b/tests/run-tests.py	Sun Apr 12 15:35:57 2015 -0400
@@ -1709,8 +1709,15 @@
 
         if self.options.with_hg:
             self._installdir = None
-            self._bindir = os.path.dirname(os.path.realpath(
-                                           self.options.with_hg))
+            whg = self.options.with_hg
+            # If --with-hg is not specified, we have bytes already,
+            # but if it was specified in python3 we get a str, so we
+            # have to encode it back into a bytes.
+            if sys.version_info[0] == 3:
+                if not isinstance(whg, bytes):
+                    whg = whg.encode('utf-8')
+            self._bindir = os.path.dirname(os.path.realpath(whg))
+            assert isinstance(self._bindir, bytes)
             self._tmpbindir = os.path.join(self._hgtmp, b'install', b'bin')
             os.makedirs(self._tmpbindir)