summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zipimport_support.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2009-11-16 06:49:25 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2009-11-16 06:49:25 (GMT)
commit260bd3e5578008682f009530faa615f74c6bcf82 (patch)
tree3dc3aab1aeb7fbe13350eba4c4437c371b4faffe /Lib/test/test_zipimport_support.py
parent36fbb730a72c0a00a2c2dc44d49b9b7af5a86174 (diff)
downloadcpython-260bd3e5578008682f009530faa615f74c6bcf82.zip
cpython-260bd3e5578008682f009530faa615f74c6bcf82.tar.gz
cpython-260bd3e5578008682f009530faa615f74c6bcf82.tar.bz2
Merged revisions 76286-76287,76289-76294,76296-76299,76301-76305,76307,76310-76311,76313-76322 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76286 | nick.coghlan | 2009-11-15 17:30:34 +1000 (Sun, 15 Nov 2009) | 1 line Issue #6816: expose the zipfile and directory execution mechanism to Python code via the runpy module. Also consolidated some script execution functionality in the test harness into a helper module and removed some implementation details from the runpy module documentation. ........ r76321 | nick.coghlan | 2009-11-16 13:55:51 +1000 (Mon, 16 Nov 2009) | 1 line Account for another cache when hunting ref leaks ........ r76322 | nick.coghlan | 2009-11-16 13:57:32 +1000 (Mon, 16 Nov 2009) | 1 line Allow for backslashes in file paths passed to the regex engine ........
Diffstat (limited to 'Lib/test/test_zipimport_support.py')
-rw-r--r--Lib/test/test_zipimport_support.py44
1 files changed, 21 insertions, 23 deletions
diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py
index 94a65fc..3a99eb7 100644
--- a/Lib/test/test_zipimport_support.py
+++ b/Lib/test/test_zipimport_support.py
@@ -14,6 +14,9 @@ import doctest
import inspect
import linecache
import pdb
+from test.script_helper import (spawn_python, kill_python, run_python,
+ temp_dir, make_script, compile_script,
+ make_pkg, make_zip_script, make_zip_pkg)
verbose = test.support.verbose
@@ -29,11 +32,6 @@ verbose = test.support.verbose
# Retrieve some helpers from other test cases
from test import test_doctest, sample_doctest
from test.test_importhooks import ImportHooksBaseTestCase
-from test.test_cmd_line_script import temp_dir, _run_python, \
- _spawn_python, _kill_python, \
- _make_test_script, \
- _compile_test_script, \
- _make_test_zip, _make_test_pkg
def _run_object_doctest(obj, module):
@@ -78,10 +76,10 @@ class ZipSupportTests(ImportHooksBaseTestCase):
def test_inspect_getsource_issue4223(self):
test_src = "def foo(): pass\n"
with temp_dir() as d:
- init_name = _make_test_script(d, '__init__', test_src)
+ init_name = make_script(d, '__init__', test_src)
name_in_zip = os.path.join('zip_pkg',
os.path.basename(init_name))
- zip_name, run_name = _make_test_zip(d, 'test_zip',
+ zip_name, run_name = make_zip_script(d, 'test_zip',
init_name, name_in_zip)
os.remove(init_name)
sys.path.insert(0, zip_name)
@@ -106,9 +104,9 @@ class ZipSupportTests(ImportHooksBaseTestCase):
sample_src = sample_src.replace("test.test_doctest",
"test_zipped_doctest")
with temp_dir() as d:
- script_name = _make_test_script(d, 'test_zipped_doctest',
+ script_name = make_script(d, 'test_zipped_doctest',
test_src)
- zip_name, run_name = _make_test_zip(d, 'test_zip',
+ zip_name, run_name = make_zip_script(d, 'test_zip',
script_name)
z = zipfile.ZipFile(zip_name, 'a')
z.writestr("sample_zipped_doctest.py", sample_src)
@@ -180,23 +178,23 @@ class ZipSupportTests(ImportHooksBaseTestCase):
""")
pattern = 'File "%s", line 2, in %s'
with temp_dir() as d:
- script_name = _make_test_script(d, 'script', test_src)
- exit_code, data = _run_python(script_name)
+ script_name = make_script(d, 'script', test_src)
+ exit_code, data = run_python(script_name)
expected = pattern % (script_name, "__main__.Test")
if verbose:
print ("Expected line", expected)
print ("Got stdout:")
print (data)
- self.assertTrue(expected in data)
- zip_name, run_name = _make_test_zip(d, "test_zip",
+ self.assertTrue(expected.encode('utf-8') in data)
+ zip_name, run_name = make_zip_script(d, "test_zip",
script_name, '__main__.py')
- exit_code, data = _run_python(zip_name)
+ exit_code, data = run_python(zip_name)
expected = pattern % (run_name, "__main__.Test")
if verbose:
print ("Expected line", expected)
print ("Got stdout:")
print (data)
- self.assertTrue(expected in data)
+ self.assertTrue(expected.encode('utf-8') in data)
def test_pdb_issue4201(self):
test_src = textwrap.dedent("""\
@@ -207,17 +205,17 @@ class ZipSupportTests(ImportHooksBaseTestCase):
pdb.runcall(f)
""")
with temp_dir() as d:
- script_name = _make_test_script(d, 'script', test_src)
- p = _spawn_python(script_name)
+ script_name = make_script(d, 'script', test_src)
+ p = spawn_python(script_name)
p.stdin.write(b'l\n')
- data = _kill_python(p).decode()
- self.assertTrue(script_name in data)
- zip_name, run_name = _make_test_zip(d, "test_zip",
+ data = kill_python(p)
+ self.assertTrue(script_name.encode('utf-8') in data)
+ zip_name, run_name = make_zip_script(d, "test_zip",
script_name, '__main__.py')
- p = _spawn_python(zip_name)
+ p = spawn_python(zip_name)
p.stdin.write(b'l\n')
- data = _kill_python(p).decode()
- self.assertTrue(run_name in data)
+ data = kill_python(p)
+ self.assertTrue(run_name.encode('utf-8') in data)
def test_main():