本文整理汇总了Python中test.script_helper.make_script函数的典型用法代码示例。如果您正苦于以下问题:Python make_script函数的具体用法?Python make_script怎么用?Python make_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_script函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_recursion_limit
def test_recursion_limit(self):
subpackage = os.path.join(self.pkgdir, 'spam')
subpackage2 = os.path.join(subpackage, 'ham')
subpackage3 = os.path.join(subpackage2, 'eggs')
for pkg in (subpackage, subpackage2, subpackage3):
script_helper.make_pkg(pkg)
subinitfn = os.path.join(subpackage, '__init__.py')
hamfn = script_helper.make_script(subpackage, 'ham', '')
spamfn = script_helper.make_script(subpackage2, 'spam', '')
eggfn = script_helper.make_script(subpackage3, 'egg', '')
self.assertRunOK('-q', '-r 0', self.pkgdir)
self.assertNotCompiled(subinitfn)
self.assertFalse(
os.path.exists(os.path.join(subpackage, '__pycache__')))
self.assertRunOK('-q', '-r 1', self.pkgdir)
self.assertCompiled(subinitfn)
self.assertCompiled(hamfn)
self.assertNotCompiled(spamfn)
self.assertRunOK('-q', '-r 2', self.pkgdir)
self.assertCompiled(subinitfn)
self.assertCompiled(hamfn)
self.assertCompiled(spamfn)
self.assertNotCompiled(eggfn)
self.assertRunOK('-q', '-r 5', self.pkgdir)
self.assertCompiled(subinitfn)
self.assertCompiled(hamfn)
self.assertCompiled(spamfn)
self.assertCompiled(eggfn)
开发者ID:Ian-Foote,项目名称:cpython,代码行数:33,代码来源:test_compileall.py
示例2: test_no_args_respects_quiet_flag
def test_no_args_respects_quiet_flag(self):
self._skip_if_sys_path_not_writable()
script_helper.make_script(self.directory, 'baz', '')
noisy = self.assertRunOK(PYTHONPATH=self.directory)
self.assertIn(b'Listing ', noisy)
quiet = self.assertRunOK('-q', PYTHONPATH=self.directory)
self.assertNotIn(b'Listing ', quiet)
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:7,代码来源:test_compileall.py
示例3: test_d_runtime_error
def test_d_runtime_error(self):
bazfn = script_helper.make_script(self.pkgdir, "baz", "raise Exception")
self.assertRunOK("-q", "-d", "dinsdale", self.pkgdir)
fn = script_helper.make_script(self.pkgdir, "bing", "import baz")
pyc = importlib.util.cache_from_source(bazfn)
os.rename(pyc, os.path.join(self.pkgdir, "baz.pyc"))
os.remove(bazfn)
rc, out, err = script_helper.assert_python_failure(fn, __isolated=False)
self.assertRegex(err, b'File "dinsdale')
开发者ID:Orav,项目名称:kbengine,代码行数:9,代码来源:test_compileall.py
示例4: _make_test_script
def _make_test_script(script_dir, script_basename,
source=test_source, omit_suffix=False):
to_return = make_script(script_dir, script_basename,
source, omit_suffix)
# Hack to check explicit relative imports
if script_basename == "check_sibling":
make_script(script_dir, "sibling", "")
importlib.invalidate_caches()
return to_return
开发者ID:alex,项目名称:cpython,代码行数:9,代码来源:test_multiprocessing_main_handling.py
示例5: setUp
def setUp(self):
self.addCleanup(self._cleanup)
self.directory = tempfile.mkdtemp()
self.pkgdir = os.path.join(self.directory, "foo")
os.mkdir(self.pkgdir)
self.pkgdir_cachedir = os.path.join(self.pkgdir, "__pycache__")
# Create the __init__.py and a package module.
self.initfn = script_helper.make_script(self.pkgdir, "__init__", "")
self.barfn = script_helper.make_script(self.pkgdir, "bar", "")
开发者ID:Orav,项目名称:kbengine,代码行数:9,代码来源:test_compileall.py
示例6: setUp
def setUp(self):
self.directory = tempfile.mkdtemp()
self.addCleanup(support.rmtree, self.directory)
self.pkgdir = os.path.join(self.directory, 'foo')
os.mkdir(self.pkgdir)
self.pkgdir_cachedir = os.path.join(self.pkgdir, '__pycache__')
# Create the __init__.py and a package module.
self.initfn = script_helper.make_script(self.pkgdir, '__init__', '')
self.barfn = script_helper.make_script(self.pkgdir, 'bar', '')
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:9,代码来源:test_compileall.py
示例7: test_multiple_dirs
def test_multiple_dirs(self):
pkgdir2 = os.path.join(self.directory, "foo2")
os.mkdir(pkgdir2)
init2fn = script_helper.make_script(pkgdir2, "__init__", "")
bar2fn = script_helper.make_script(pkgdir2, "bar2", "")
self.assertRunOK("-q", self.pkgdir, pkgdir2)
self.assertCompiled(self.initfn)
self.assertCompiled(self.barfn)
self.assertCompiled(init2fn)
self.assertCompiled(bar2fn)
开发者ID:Orav,项目名称:kbengine,代码行数:10,代码来源:test_compileall.py
示例8: test_multiple_dirs
def test_multiple_dirs(self):
pkgdir2 = os.path.join(self.directory, 'foo2')
os.mkdir(pkgdir2)
init2fn = script_helper.make_script(pkgdir2, '__init__', '')
bar2fn = script_helper.make_script(pkgdir2, 'bar2', '')
self.assertRunOK('-q', self.pkgdir, pkgdir2)
self.assertCompiled(self.initfn)
self.assertCompiled(self.barfn)
self.assertCompiled(init2fn)
self.assertCompiled(bar2fn)
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:10,代码来源:test_compileall.py
示例9: test_recursion_control
def test_recursion_control(self):
subpackage = os.path.join(self.pkgdir, 'spam')
os.mkdir(subpackage)
subinitfn = script_helper.make_script(subpackage, '__init__', '')
hamfn = script_helper.make_script(subpackage, 'ham', '')
self.assertRunOK('-q', '-l', self.pkgdir)
self.assertNotCompiled(subinitfn)
self.assertFalse(os.path.exists(os.path.join(subpackage, '__pycache__')))
self.assertRunOK('-q', self.pkgdir)
self.assertCompiled(subinitfn)
self.assertCompiled(hamfn)
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:11,代码来源:test_compileall.py
示例10: test_recursion_control
def test_recursion_control(self):
subpackage = os.path.join(self.pkgdir, "spam")
os.mkdir(subpackage)
subinitfn = script_helper.make_script(subpackage, "__init__", "")
hamfn = script_helper.make_script(subpackage, "ham", "")
self.assertRunOK("-q", "-l", self.pkgdir)
self.assertNotCompiled(subinitfn)
self.assertFalse(os.path.exists(os.path.join(subpackage, "__pycache__")))
self.assertRunOK("-q", self.pkgdir)
self.assertCompiled(subinitfn)
self.assertCompiled(hamfn)
开发者ID:Orav,项目名称:kbengine,代码行数:11,代码来源:test_compileall.py
示例11: test_include_file_no_arg
def test_include_file_no_arg(self):
f1 = script_helper.make_script(self.pkgdir, "f1", "")
f2 = script_helper.make_script(self.pkgdir, "f2", "")
f3 = script_helper.make_script(self.pkgdir, "f3", "")
f4 = script_helper.make_script(self.pkgdir, "f4", "")
with open(os.path.join(self.directory, "l1"), "w") as l1:
l1.write(os.path.join(self.pkgdir, "f2.py") + os.linesep)
self.assertRunOK("-i", os.path.join(self.directory, "l1"))
self.assertNotCompiled(f1)
self.assertCompiled(f2)
self.assertNotCompiled(f3)
self.assertNotCompiled(f4)
开发者ID:Orav,项目名称:kbengine,代码行数:12,代码来源:test_compileall.py
示例12: test_include_file_no_arg
def test_include_file_no_arg(self):
f1 = script_helper.make_script(self.pkgdir, 'f1', '')
f2 = script_helper.make_script(self.pkgdir, 'f2', '')
f3 = script_helper.make_script(self.pkgdir, 'f3', '')
f4 = script_helper.make_script(self.pkgdir, 'f4', '')
with open(os.path.join(self.directory, 'l1'), 'w') as l1:
l1.write(os.path.join(self.pkgdir, 'f2.py')+os.linesep)
self.assertRunOK('-i', os.path.join(self.directory, 'l1'))
self.assertNotCompiled(f1)
self.assertCompiled(f2)
self.assertNotCompiled(f3)
self.assertNotCompiled(f4)
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:12,代码来源:test_compileall.py
示例13: test_include_on_stdin
def test_include_on_stdin(self):
f1 = script_helper.make_script(self.pkgdir, 'f1', '')
f2 = script_helper.make_script(self.pkgdir, 'f2', '')
f3 = script_helper.make_script(self.pkgdir, 'f3', '')
f4 = script_helper.make_script(self.pkgdir, 'f4', '')
p = script_helper.spawn_python(*(self._get_run_args(()) + ['-i', '-']))
p.stdin.write((f3+os.linesep).encode('ascii'))
script_helper.kill_python(p)
self.assertNotCompiled(f1)
self.assertNotCompiled(f2)
self.assertCompiled(f3)
self.assertNotCompiled(f4)
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:12,代码来源:test_compileall.py
示例14: test_include_on_stdin
def test_include_on_stdin(self):
f1 = script_helper.make_script(self.pkgdir, "f1", "")
f2 = script_helper.make_script(self.pkgdir, "f2", "")
f3 = script_helper.make_script(self.pkgdir, "f3", "")
f4 = script_helper.make_script(self.pkgdir, "f4", "")
p = script_helper.spawn_python(*(self._get_run_args(()) + ["-i", "-"]))
p.stdin.write((f3 + os.linesep).encode("ascii"))
script_helper.kill_python(p)
self.assertNotCompiled(f1)
self.assertNotCompiled(f2)
self.assertCompiled(f3)
self.assertNotCompiled(f4)
开发者ID:Orav,项目名称:kbengine,代码行数:12,代码来源:test_compileall.py
示例15: test_workers
def test_workers(self):
bar2fn = script_helper.make_script(self.directory, 'bar2', '')
files = []
for suffix in range(5):
pkgdir = os.path.join(self.directory, 'foo{}'.format(suffix))
os.mkdir(pkgdir)
fn = script_helper.make_script(pkgdir, '__init__', '')
files.append(script_helper.make_script(pkgdir, 'bar2', ''))
self.assertRunOK(self.directory, '-j', '0')
self.assertCompiled(bar2fn)
for file in files:
self.assertCompiled(file)
开发者ID:Ian-Foote,项目名称:cpython,代码行数:13,代码来源:test_compileall.py
示例16: test_unencodable_filename
def test_unencodable_filename(self):
# Issue #11619: The Python parser and the import machinery must not
# encode filenames, especially on Windows
pyname = script_helper.make_script('', TESTFN_UNENCODABLE, 'pass')
name = pyname[:-3]
script_helper.assert_python_ok("-c", "mod = __import__(%a)" % name,
__isolated=False)
开发者ID:0jpq0,项目名称:kbengine,代码行数:7,代码来源:test_import.py
示例17: 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
示例18: _make_launch_script
def _make_launch_script(script_dir, script_basename, module_name, path=None):
if path is None:
path = "os.path.dirname(__file__)"
else:
path = repr(path)
source = launch_source % (path, module_name)
return make_script(script_dir, script_basename, source)
开发者ID:EnviroCentre,项目名称:jython-upgrade,代码行数:7,代码来源:test_cmd_line_script.py
示例19: test_compiles_as_much_as_possible
def test_compiles_as_much_as_possible(self):
bingfn = script_helper.make_script(self.pkgdir, "bing", "syntax(error")
rc, out, err = self.assertRunNotOK("nosuchfile", self.initfn, bingfn, self.barfn)
self.assertRegex(out, b"rror")
self.assertNotCompiled(bingfn)
self.assertCompiled(self.initfn)
self.assertCompiled(self.barfn)
开发者ID:Orav,项目名称:kbengine,代码行数:7,代码来源:test_compileall.py
示例20: test_no_args_compiles_path
def test_no_args_compiles_path(self):
# Note that -l is implied for the no args case.
bazfn = script_helper.make_script(self.directory, 'baz', '')
self.assertRunOK(PYTHONPATH=self.directory)
self.assertCompiled(bazfn)
self.assertNotCompiled(self.initfn)
self.assertNotCompiled(self.barfn)
开发者ID:Ian-Foote,项目名称:cpython,代码行数:7,代码来源:test_compileall.py
注:本文中的test.script_helper.make_script函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论