tests: do not mangle sys.path

Summary:
Mangling `sys.path` in `.py` tests could break tests running with `buck` opt
build. Because the bundled extensions won't be used, but files in the working
copy will. It's okay-ish for pure Python extensions. But native extensions will
have problems.

Reviewed By: ryanmce

Differential Revision: D6974954

fbshipit-source-id: 8a7f3d86e5c2fbf16cfcc971743d99585fe61b99
This commit is contained in:
Jun Wu 2018-02-14 20:21:02 -08:00 committed by Saurabh Singh
parent 6ecd47c391
commit 51be4ac4b9
8 changed files with 2 additions and 33 deletions

View File

@ -1,11 +1,6 @@
from __future__ import absolute_import
import itertools
import os
import sys
# make it runnable directly without run-tests.py
sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')]
from hgext import absorb

View File

@ -2,7 +2,6 @@
import errno
import os
import sys
import time
import unittest
@ -14,10 +13,7 @@ from mercurial import (
worker,
)
if __name__ == '__main__':
sys.path.insert(0, os.path.join(os.environ["TESTDIR"], "..", "hgext"))
import extutil
from hgext import extutil
locktimeout = 25
locksuccess = 24

View File

@ -4,9 +4,6 @@ import os
import sys
import tempfile
# make it runnable using python directly without run-tests.py
sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')]
from hgext.fastannotate import error, revmap
try:

View File

@ -1,7 +1,6 @@
import silenttestrunner
import unittest
import os
import sys
import time
from mercurial import error
@ -174,6 +173,5 @@ class HybridManifest(unittest.TestCase):
lambda: vfs.lstat("lock"))
if __name__ == "__main__":
sys.path.insert(0, os.path.join(os.environ["TESTDIR"], ".."))
from hgext import fastmanifest
silenttestrunner.main(__name__)

View File

@ -1,7 +1,5 @@
import unittest
import os
import silenttestrunner
import sys
class BisectTests(unittest.TestCase):
def testSimple(self):
@ -51,6 +49,5 @@ class BisectTests(unittest.TestCase):
self.assertEqual(bisect(0, len(array) - 1, comp, value), result)
if __name__ == '__main__':
sys.path.insert(0, os.path.join(os.environ["TESTDIR"], "..", "hgext"))
from generic_bisect import bisect
from hgext.generic_bisect import bisect
silenttestrunner.main(__name__)

View File

@ -3,9 +3,6 @@ from __future__ import absolute_import, print_function
import os
import sys
# make it runnable directly without run-tests.py
sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')]
if not sys.platform.startswith('linux'):
sys.stderr.write('skipped: linux required\n')
sys.exit(80)

View File

@ -1,11 +1,5 @@
from __future__ import absolute_import, print_function
import os
import sys
# make it runnable using python directly without run-tests.py
sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')]
from hgext.lfs import pointer
def tryparse(text):

View File

@ -1,12 +1,7 @@
from __future__ import absolute_import, print_function
import os
import sys
import tempfile
# make it runnable using python directly without run-tests.py
sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')]
from hgext import linkrevcache
try: