def test_setup_bootstrap_path(self): # Check how sys.path is handled depending on if we can find a copy of # the stdlib in setup_bootstrap_path. import sys, os old_sys_path = sys.path[:] old_cwd = os.getcwd() sys.path.append(self.goal_dir) # make sure cwd does not contain a stdlib if self.tmp_dir.startswith(self.trunkdir): skip('TMPDIR is inside the PyPy source') os.chdir(self.tmp_dir) tmp_pypy_c = os.path.join(self.tmp_dir, 'pypy-c') try: import app_main app_main.setup_bootstrap_path(tmp_pypy_c) # stdlib not found assert sys.executable == '' assert sys.path == old_sys_path + [self.goal_dir] app_main.setup_bootstrap_path(self.fake_exe) assert sys.executable == self.fake_exe assert self.goal_dir not in sys.path newpath = sys.path[:] if newpath[0].endswith('__extensions__'): newpath = newpath[1:] # we get at least 'expected_path', and maybe more (e.g.plat-linux2) assert newpath[:len(self.expected_path)] == self.expected_path finally: sys.path[:] = old_sys_path os.chdir(old_cwd)
def test_trunk_can_be_prefix(self): import sys import os old_sys_path = sys.path[:] sys.path.append(self.goal_dir) try: import app_main pypy_c = os.path.join(self.trunkdir, 'pypy', 'goal', 'pypy-c') app_main.setup_bootstrap_path(pypy_c) newpath = sys.path[:] # we get at least lib_pypy # lib-python/X.Y.Z, and maybe more (e.g. plat-linux2) assert len(newpath) >= 2 for p in newpath: assert p.startswith(self.trunkdir) finally: sys.path[:] = old_sys_path
def test_setup_bootstrap_path(self): import sys old_sys_path = sys.path[:] sys.path.append(self.goal_dir) try: import app_main app_main.setup_bootstrap_path('/tmp/pypy-c') # stdlib not found assert sys.executable == '' assert sys.path == old_sys_path + [self.goal_dir] app_main.setup_bootstrap_path(self.fake_exe) assert sys.executable == self.fake_exe assert self.goal_dir not in sys.path newpath = sys.path[:] if newpath[0].endswith('__extensions__'): newpath = newpath[1:] # we get at least 'expected_path', and maybe more (e.g.plat-linux2) assert newpath[:len(self.expected_path)] == self.expected_path finally: sys.path[:] = old_sys_path
def test_setup_bootstrap_path(self): import sys old_sys_path = sys.path[:] sys.path.append(self.goal_dir) try: import app_main app_main.setup_bootstrap_path("/tmp/pypy-c") # stdlib not found assert sys.executable == "" assert sys.path == old_sys_path + [self.goal_dir] app_main.setup_bootstrap_path(self.fake_exe) assert sys.executable == self.fake_exe assert self.goal_dir not in sys.path newpath = sys.path[:] if newpath[0].endswith("__extensions__"): newpath = newpath[1:] # we get at least 'expected_path', and maybe more (e.g.plat-linux2) assert newpath[: len(self.expected_path)] == self.expected_path finally: sys.path[:] = old_sys_path
def test_setup_bootstrap_path(self): # Check how sys.path is handled depending on if we can find a copy of # the stdlib in setup_bootstrap_path. import sys, os old_sys_path = sys.path[:] old_cwd = os.getcwd() # make sure cwd does not contain a stdlib if self.tmp_dir.startswith(self.trunkdir): skip('TMPDIR is inside the PyPy source') sys.path.append(self.goal_dir) tmp_pypy_c = os.path.join(self.tmp_dir, 'pypy-c') try: os.chdir(self.tmp_dir) # If we are running PyPy with a libpypy-c, the following # lines find the stdlib anyway. Otherwise, it is not found. expected_found = ( getattr(sys, 'pypy_translation_info', {}) .get('translation.shared')) import app_main app_main.setup_bootstrap_path(tmp_pypy_c) assert sys.executable == '' if not expected_found: assert sys.path == old_sys_path + [self.goal_dir] app_main.setup_bootstrap_path(self.fake_exe) if not sys.platform == 'win32': # an existing file is always 'executable' on windows assert sys.executable == '' # not executable! if not expected_found: assert sys.path == old_sys_path + [self.goal_dir] os.chmod(self.fake_exe, 0755) app_main.setup_bootstrap_path(self.fake_exe) assert sys.executable == self.fake_exe assert self.goal_dir not in sys.path newpath = sys.path[:] if newpath[0].endswith('__extensions__'): newpath = newpath[1:] # we get at least 'expected_path', and maybe more (e.g.plat-linux2) if not expected_found: assert newpath[:len(self.expected_path)] == self.expected_path finally: sys.path[:] = old_sys_path os.chdir(old_cwd)
def test_setup_bootstrap_path(self): # Check how sys.path is handled depending on if we can find a copy of # the stdlib in setup_bootstrap_path. import sys, os old_sys_path = sys.path[:] old_cwd = os.getcwd() sys.path.append(self.goal_dir) # make sure cwd does not contain a stdlib if self.tmp_dir.startswith(self.trunkdir): skip("TMPDIR is inside the PyPy source") os.chdir(self.tmp_dir) tmp_pypy_c = os.path.join(self.tmp_dir, "pypy-c") try: import app_main app_main.setup_bootstrap_path(tmp_pypy_c) # stdlib not found assert sys.executable == "" assert sys.path == old_sys_path + [self.goal_dir] app_main.setup_bootstrap_path(self.fake_exe) if not sys.platform == "win32": # an existing file is always 'executable' on windows assert sys.executable == "" # not executable! assert sys.path == old_sys_path + [self.goal_dir] os.chmod(self.fake_exe, 0755) app_main.setup_bootstrap_path(self.fake_exe) assert sys.executable == self.fake_exe assert self.goal_dir not in sys.path newpath = sys.path[:] if newpath[0].endswith("__extensions__"): newpath = newpath[1:] # we get at least 'expected_path', and maybe more (e.g.plat-linux2) assert newpath[: len(self.expected_path)] == self.expected_path finally: sys.path[:] = old_sys_path os.chdir(old_cwd)
def test_setup_bootstrap_path(self): # Check how sys.path is handled depending on if we can find a copy of # the stdlib in setup_bootstrap_path. import sys, os old_sys_path = sys.path[:] old_cwd = os.getcwd() sys.path.append(self.goal_dir) # make sure cwd does not contain a stdlib if self.tmp_dir.startswith(self.trunkdir): skip('TMPDIR is inside the PyPy source') os.chdir(self.tmp_dir) tmp_pypy_c = os.path.join(self.tmp_dir, 'pypy-c') try: import app_main app_main.setup_bootstrap_path(tmp_pypy_c) # stdlib not found assert sys.executable == '' assert sys.path == old_sys_path + [self.goal_dir] app_main.setup_bootstrap_path(self.fake_exe) if not sys.platform == 'win32': # an existing file is always 'executable' on windows assert sys.executable == '' # not executable! assert sys.path == old_sys_path + [self.goal_dir] os.chmod(self.fake_exe, 0755) app_main.setup_bootstrap_path(self.fake_exe) assert sys.executable == self.fake_exe assert self.goal_dir not in sys.path newpath = sys.path[:] if newpath[0].endswith('__extensions__'): newpath = newpath[1:] # we get at least 'expected_path', and maybe more (e.g.plat-linux2) assert newpath[:len(self.expected_path)] == self.expected_path finally: sys.path[:] = old_sys_path os.chdir(old_cwd)