def test_proxy_directory(self): """ Test we handle correctly entries of the form 'path some_directory'. """ with mkdtemp() as prefix: with mock.patch("sys.executable", op.join(prefix, "python.exe")): egginst = EggInst(DUMMY_EGG_WITH_PROXY_SCRIPTS, prefix) with zipfile.ZipFile(egginst.path) as zp: egginst.z = zp egginst.arcnames = zp.namelist() create_proxies(egginst) proxied_files = [op.join(prefix, "Scripts", "dummy.dll"), op.join(prefix, "Scripts", "dummy.lib")] for proxied_file in proxied_files: self.assertTrue(op.exists(proxied_file))
def test_proxy(self): """ Test we handle correctly entries of the form 'path PROXY'. """ r_python_proxy_data_template = """\ #!"%(executable)s" # This proxy was created by egginst from an egg with special instructions # import sys import subprocess src = %(src)r sys.exit(subprocess.call([src] + sys.argv[1:])) """ with mkdtemp() as prefix: pythonexe = os.path.join(prefix, "python.exe") proxy_path = os.path.join( prefix, "EGG-INFO", "dummy_with_proxy", "usr", "swig.exe" ) if PY2: proxy_path = proxy_path.decode("utf8") r_python_proxy_data = r_python_proxy_data_template % \ {'executable': pythonexe, 'src': proxy_path} runtime_info = self._runtime_info_factory(prefix) egginst = EggInst(DUMMY_EGG_WITH_PROXY, runtime_info=runtime_info) with ZipFile(egginst.path) as zp: egginst.z = zp egginst.arcnames = zp.namelist() create_proxies(egginst, pythonexe) python_proxy = os.path.join(prefix, "Scripts", "swig-script.py") coff_proxy = os.path.join(prefix, "Scripts", "swig.exe") self.assertTrue(os.path.exists(python_proxy)) self.assertTrue(os.path.exists(coff_proxy)) self.assertTrue(compute_md5(coff_proxy), hashlib.md5(exe_data.cli).hexdigest()) with open(python_proxy, "rt") as fp: python_proxy_data = fp.read() self.assertMultiLineEqual(python_proxy_data, r_python_proxy_data)
def test_proxy_directory(self): """ Test we handle correctly entries of the form 'path some_directory'. """ with mkdtemp() as prefix: with mock.patch("sys.executable", os.path.join(prefix, "python.exe")): egginst = EggInst(DUMMY_EGG_WITH_PROXY_SCRIPTS, prefix) with ZipFile(egginst.path) as zp: egginst.z = zp egginst.arcnames = zp.namelist() create_proxies(egginst) proxied_files = [ os.path.join(prefix, "Scripts", "dummy.dll"), os.path.join(prefix, "Scripts", "dummy.lib"), ] for proxied_file in proxied_files: self.assertTrue(os.path.exists(proxied_file))
def test_proxy(self): """ Test we handle correctly entries of the form 'path PROXY'. """ r_python_proxy_data_template = """\ #!"%(executable)s" # This proxy was created by egginst from an egg with special instructions # import sys import subprocess src = %(src)r sys.exit(subprocess.call([src] + sys.argv[1:])) """ with mkdtemp() as prefix: with mock.patch("sys.executable", os.path.join(prefix, "python.exe")): proxy_path = os.path.join(prefix, "EGG-INFO", "dummy_with_proxy", "usr", "swig.exe") if PY2: proxy_path = proxy_path.decode("utf8") r_python_proxy_data = r_python_proxy_data_template % \ {'executable': os.path.join(prefix, "python.exe"), 'src': proxy_path} egginst = EggInst(DUMMY_EGG_WITH_PROXY, prefix) with ZipFile(egginst.path) as zp: egginst.z = zp egginst.arcnames = zp.namelist() create_proxies(egginst) python_proxy = os.path.join(prefix, "Scripts", "swig-script.py") coff_proxy = os.path.join(prefix, "Scripts", "swig.exe") self.assertTrue(os.path.exists(python_proxy)) self.assertTrue(os.path.exists(coff_proxy)) self.assertTrue(compute_md5(coff_proxy), hashlib.md5(exe_data.cli).hexdigest()) with open(python_proxy, "rt") as fp: python_proxy_data = fp.read() self.assertMultiLineEqual(python_proxy_data, r_python_proxy_data)
def test_proxy(self): """ Test we handle correctly entries of the form 'path PROXY'. """ r_python_proxy_data_template = """\ #!"{executable}" # This proxy was created by egginst from an egg with special instructions # import sys import subprocess src = '{src}' sys.exit(subprocess.call([src] + sys.argv[1:])) """ with mkdtemp() as prefix: with mock.patch("sys.executable", os.path.join(prefix, "python.exe")): proxy_path = os.path.join(prefix, "EGG-INFO", "dummy_with_proxy", "usr", "swig.exe") r_python_proxy_data = r_python_proxy_data_template.format( executable=os.path.join(prefix, "python.exe"), src=escape_win32_path(proxy_path)) egginst = EggInst(DUMMY_EGG_WITH_PROXY, prefix) with ZipFile(egginst.path) as zp: egginst.z = zp egginst.arcnames = zp.namelist() create_proxies(egginst) python_proxy = os.path.join(prefix, "Scripts", "swig-script.py") coff_proxy = os.path.join(prefix, "Scripts", "swig.exe") self.assertTrue(os.path.exists(python_proxy)) self.assertTrue(os.path.exists(coff_proxy)) self.assertTrue(md5_file(coff_proxy), hashlib.md5(exe_data.cli).hexdigest()) with open(python_proxy) as fp: python_proxy_data = fp.read() self.assertMultiLineEqual( python_proxy_data, r_python_proxy_data)