diff --git a/tests/run-tests.py b/tests/run-tests.py
index a1de4ffaa7a8fd1590048e39c5ed61c1f96c21f3_dGVzdHMvcnVuLXRlc3RzLnB5..57d56f603f7062d9c5a0f6d9c4bf39e1a26c5388_dGVzdHMvcnVuLXRlc3RzLnB5 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2356,9 +2356,9 @@
         # assume all tests in same folder for now
         if testdescs:
             pathname = os.path.dirname(testdescs[0]['path'])
-            if pathname and not osenvironb[b'TESTDIR'].endswith(b'/'):
-                osenvironb[b'TESTDIR'] += b'/'
-            osenvironb[b'TESTDIR'] += pathname
+            if pathname:
+                osenvironb[b'TESTDIR'] = os.path.join(osenvironb[b'TESTDIR'],
+                                                      pathname)
         if self.options.outputdir:
             self._outputdir = canonpath(_bytespath(self.options.outputdir))
         else: