本文整理汇总了Python中test.script_helper.make_zip_script函数的典型用法代码示例。如果您正苦于以下问题:Python make_zip_script函数的具体用法?Python make_zip_script怎么用?Python make_zip_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_zip_script函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_zipfile_compiled
def test_zipfile_compiled(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
compiled_name = py_compile.compile(script_name, doraise=True)
zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name)
self._check_script(zip_name, run_name, zip_name, zip_name, '',
zipimport.zipimporter)
开发者ID:BeboPremo,项目名称:cpython,代码行数:7,代码来源:test_cmd_line_script.py
示例2: test_doctest_main_issue4197
def test_doctest_main_issue4197(self):
test_src = textwrap.dedent("""\
class Test:
">>> 'line 2'"
pass
import doctest
doctest.testmod()
""")
pattern = 'File "%s", line 2, in %s'
with temp_dir() as d:
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.assertIn(expected, data)
zip_name, run_name = make_zip_script(d, "test_zip",
script_name, '__main__.py')
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.assertIn(expected, data)
开发者ID:aepstein,项目名称:python,代码行数:28,代码来源:test_zipimport_support.py
示例3: test_zipfile_error
def test_zipfile_error(self):
with temp_dir() as script_dir:
mod_name = 'not_main'
script_name = self._make_test_script(script_dir, mod_name)
zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name)
msg = "can't find '__main__' module in %r" % zip_name
self._check_import_error(zip_name, msg)
开发者ID:edmundgentle,项目名称:schoolscript,代码行数:7,代码来源:test_runpy.py
示例4: test_zipfile
def test_zipfile(self):
with temp_dir() as script_dir:
mod_name = '__main__'
script_name = self._make_test_script(script_dir, mod_name)
zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name)
self._check_script(zip_name, "<run_path>", fname, zip_name,
mod_name=mod_name, check_loader=False)
开发者ID:isaiah,项目名称:jython3,代码行数:7,代码来源:test_runpy.py
示例5: test_zipfile
def test_zipfile(self):
source = self.main_in_children_source
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__',
source=source)
zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name)
self._check_script(zip_name)
开发者ID:alex,项目名称:cpython,代码行数:7,代码来源:test_multiprocessing_main_handling.py
示例6: test_zipfile_compiled
def test_zipfile_compiled(self):
with temp_dir() as script_dir:
mod_name = '__main__'
script_name = self._make_test_script(script_dir, mod_name)
compiled_name = compile_script(script_name)
zip_name, fname = make_zip_script(script_dir, 'test_zip', compiled_name)
self._check_script(zip_name, "<run_path>", fname, zip_name, '')
开发者ID:mozillazg,项目名称:pypy,代码行数:7,代码来源:test_runpy.py
示例7: test_zipfile_compiled
def test_zipfile_compiled(self):
with temp_dir() as script_dir:
mod_name = "__main__"
script_name = self._make_test_script(script_dir, mod_name)
compiled_name = py_compile.compile(script_name, doraise=True)
zip_name, fname = make_zip_script(script_dir, "test_zip", compiled_name)
self._check_script(zip_name, "<run_path>", fname, zip_name, "")
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:7,代码来源:test_runpy.py
示例8: test_main_recursion_error
def test_main_recursion_error(self):
with temp_dir() as script_dir, temp_dir() as dummy_dir:
mod_name = "__main__"
source = ("import runpy\n" "runpy.run_path(%r)\n") % dummy_dir
script_name = self._make_test_script(script_dir, mod_name, source)
zip_name, fname = make_zip_script(script_dir, "test_zip", script_name)
msg = "recursion depth exceeded"
self.assertRaisesRegexp(RuntimeError, msg, run_path, zip_name)
开发者ID:lzjun567,项目名称:python2.7,代码行数:8,代码来源:test_runpy.py
示例9: test_zipfile_compiled
def test_zipfile_compiled(self):
source = self.main_in_children_source
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__',
source=source)
compiled_name = py_compile.compile(script_name, doraise=True)
zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name)
self._check_script(zip_name)
开发者ID:alex,项目名称:cpython,代码行数:8,代码来源:test_multiprocessing_main_handling.py
示例10: test_zipfile_compiled
def test_zipfile_compiled(self):
with temp_dir() as script_dir:
mod_name = '__main__'
script_name = self._make_test_script(script_dir, mod_name)
compiled_name = py_compile.compile(script_name, doraise=True)
zip_name, fname = make_zip_script(script_dir, 'test_zip',
compiled_name)
self._check_script(zip_name, "<run_path>", fname, zip_name,
mod_name=mod_name, check_loader=False)
开发者ID:isaiah,项目名称:jython3,代码行数:9,代码来源:test_runpy.py
示例11: test_inspect_getsource_issue4223
def test_inspect_getsource_issue4223(self):
test_src = "def foo(): pass\n"
with temp_dir() as d:
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_zip_script(d, 'test_zip',
init_name, name_in_zip)
os.remove(init_name)
sys.path.insert(0, zip_name)
import zip_pkg
self.assertEqual(inspect.getsource(zip_pkg.foo), test_src)
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:12,代码来源:test_zipimport_support.py
示例12: test_inspect_getsource_issue4223
def test_inspect_getsource_issue4223(self):
test_src = "def foo(): pass\n"
with temp_dir() as d:
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_zip_script(d, "test_zip", init_name, name_in_zip)
os.remove(init_name)
sys.path.insert(0, zip_name)
import zip_pkg
try:
self.assertEqual(inspect.getsource(zip_pkg.foo), test_src)
finally:
del sys.modules["zip_pkg"]
开发者ID:sdsgwangpeng,项目名称:kbengine,代码行数:14,代码来源:test_zipimport_support.py
示例13: test_pdb_issue4201
def test_pdb_issue4201(self):
test_src = textwrap.dedent("""\
def f():
pass
import pdb
pdb.Pdb(nosigint=True).runcall(f)
""")
with temp_dir() as d:
script_name = make_script(d, 'script', test_src)
p = spawn_python(script_name)
p.stdin.write(b'l\n')
data = kill_python(p)
# bdb/pdb applies normcase to its filename before displaying
self.assertIn(os.path.normcase(script_name.encode('utf-8')), data)
zip_name, run_name = make_zip_script(d, "test_zip",
script_name, '__main__.py')
p = spawn_python(zip_name)
p.stdin.write(b'l\n')
data = kill_python(p)
# bdb/pdb applies normcase to its filename before displaying
self.assertIn(os.path.normcase(run_name.encode('utf-8')), data)
开发者ID:0jpq0,项目名称:kbengine,代码行数:22,代码来源:test_zipimport_support.py
示例14: test_pdb_issue4201
def test_pdb_issue4201(self):
test_src = textwrap.dedent("""\
def f():
pass
import pdb
pdb.runcall(f)
""")
with temp_dir() as d:
script_name = make_script(d, 'script', test_src)
p = spawn_python(script_name)
p.stdin.write('l\n')
data = kill_python(p)
# Back-port from CPython 3 (see CPython Issue 14255).
self.assertNormalisedIn(script_name, data)
zip_name, run_name = make_zip_script(d, "test_zip",
script_name, '__main__.py')
p = spawn_python(zip_name)
p.stdin.write('l\n')
data = kill_python(p)
# Back-port from CPython 3 (see CPython Issue 14255).
self.assertNormalisedIn(run_name, data)
开发者ID:Stewori,项目名称:jython,代码行数:24,代码来源:test_zipimport_support.py
示例15: test_zipfile
def test_zipfile(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, "__main__")
zip_name, run_name = make_zip_script(script_dir, "test_zip", script_name)
self._check_script(zip_name, run_name, zip_name, "")
开发者ID:hsienchieh,项目名称:uefilab,代码行数:5,代码来源:test_cmd_line_script.py
示例16: test_zipfile
def test_zipfile(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name)
self._check_script(zip_name, run_name, zip_name, zip_name, '',
zipimport.zipimporter)
开发者ID:BeboPremo,项目名称:cpython,代码行数:6,代码来源:test_cmd_line_script.py
示例17: test_zipfile_compiled
def test_zipfile_compiled(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
compiled_name = compile_script(script_name)
zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name)
self._check_script(zip_name, run_name, zip_name, '')
开发者ID:EnviroCentre,项目名称:jython-upgrade,代码行数:6,代码来源:test_cmd_line_script.py
示例18: test_zipfile_error
def test_zipfile_error(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, "not_main")
zip_name, run_name = make_zip_script(script_dir, "test_zip", script_name)
msg = "can't find '__main__' module in %r" % zip_name
self._check_import_error(zip_name, msg)
开发者ID:hsienchieh,项目名称:uefilab,代码行数:6,代码来源:test_cmd_line_script.py
示例19: test_zipfile
def test_zipfile(self):
with temp_dir() as script_dir:
mod_name = "__main__"
script_name = self._make_test_script(script_dir, mod_name)
zip_name, fname = make_zip_script(script_dir, "test_zip", script_name)
self._check_script(zip_name, "<run_path>", fname, zip_name, "")
开发者ID:lzjun567,项目名称:python2.7,代码行数:6,代码来源:test_runpy.py
示例20: test_doctest_issue4197
def test_doctest_issue4197(self):
# To avoid having to keep two copies of the doctest module's
# unit tests in sync, this test works by taking the source of
# test_doctest itself, rewriting it a bit to cope with a new
# location, and then throwing it in a zip file to make sure
# everything still works correctly
test_src = inspect.getsource(test_doctest)
test_src = test_src.replace(
"from test import test_doctest",
"import test_zipped_doctest as test_doctest")
test_src = test_src.replace("test.test_doctest",
"test_zipped_doctest")
test_src = test_src.replace("test.sample_doctest",
"sample_zipped_doctest")
sample_src = inspect.getsource(sample_doctest)
sample_src = sample_src.replace("test.test_doctest",
"test_zipped_doctest")
with temp_dir() as d:
script_name = make_script(d, 'test_zipped_doctest',
test_src)
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)
z.close()
if verbose:
zip_file = zipfile.ZipFile(zip_name, 'r')
print 'Contents of %r:' % zip_name
zip_file.printdir()
zip_file.close()
os.remove(script_name)
sys.path.insert(0, zip_name)
import test_zipped_doctest
# Some of the doc tests depend on the colocated text files
# which aren't available to the zipped version (the doctest
# module currently requires real filenames for non-embedded
# tests). So we're forced to be selective about which tests
# to run.
# doctest could really use some APIs which take a text
# string or a file object instead of a filename...
known_good_tests = [
test_zipped_doctest.SampleClass,
test_zipped_doctest.SampleClass.NestedClass,
test_zipped_doctest.SampleClass.NestedClass.__init__,
test_zipped_doctest.SampleClass.__init__,
test_zipped_doctest.SampleClass.a_classmethod,
test_zipped_doctest.SampleClass.a_property,
test_zipped_doctest.SampleClass.a_staticmethod,
test_zipped_doctest.SampleClass.double,
test_zipped_doctest.SampleClass.get,
test_zipped_doctest.SampleNewStyleClass,
test_zipped_doctest.SampleNewStyleClass.__init__,
test_zipped_doctest.SampleNewStyleClass.double,
test_zipped_doctest.SampleNewStyleClass.get,
test_zipped_doctest.old_test1,
test_zipped_doctest.old_test2,
test_zipped_doctest.old_test3,
test_zipped_doctest.old_test4,
test_zipped_doctest.sample_func,
test_zipped_doctest.test_DocTest,
test_zipped_doctest.test_DocTestParser,
test_zipped_doctest.test_DocTestRunner.basics,
test_zipped_doctest.test_DocTestRunner.exceptions,
test_zipped_doctest.test_DocTestRunner.option_directives,
test_zipped_doctest.test_DocTestRunner.optionflags,
test_zipped_doctest.test_DocTestRunner.verbose_flag,
test_zipped_doctest.test_Example,
test_zipped_doctest.test_debug,
test_zipped_doctest.test_pdb_set_trace,
test_zipped_doctest.test_pdb_set_trace_nested,
test_zipped_doctest.test_testsource,
test_zipped_doctest.test_trailing_space_in_test,
test_zipped_doctest.test_DocTestSuite,
test_zipped_doctest.test_DocTestFinder,
]
# These remaining tests are the ones which need access
# to the data files, so we don't run them
fail_due_to_missing_data_files = [
test_zipped_doctest.test_DocFileSuite,
test_zipped_doctest.test_testfile,
test_zipped_doctest.test_unittest_reportflags,
]
# Needed for test_DocTestParser and test_debug
deprecations = [
# Ignore all warnings about the use of class Tester in this module.
("class Tester is deprecated", DeprecationWarning)]
if sys.py3kwarning:
deprecations += [
("backquote not supported", SyntaxWarning),
("execfile.. not supported", DeprecationWarning)]
with test.test_support.check_warnings(*deprecations):
for obj in known_good_tests:
_run_object_doctest(obj, test_zipped_doctest)
开发者ID:onealj,项目名称:jython-2.7-log-backwards-compatibility,代码行数:93,代码来源:test_zipimport_support.py
注:本文中的test.script_helper.make_zip_script函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论