本文整理汇总了Python中test.support.script_helper.make_script函数的典型用法代码示例。如果您正苦于以下问题:Python make_script函数的具体用法?Python make_script怎么用?Python make_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_script函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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:1st1,项目名称:cpython,代码行数:7,代码来源:test_compileall.py
示例2: 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:rayeya,项目名称:cpython,代码行数:32,代码来源:test_compileall.py
示例3: 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:rayeya,项目名称:cpython,代码行数:7,代码来源:test_compileall.py
示例4: 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:1st1,项目名称:cpython,代码行数:33,代码来源:test_compileall.py
示例5: 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:1st1,项目名称:cpython,代码行数: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:1st1,项目名称:cpython,代码行数:9,代码来源:test_compileall.py
示例7: _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:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:9,代码来源:test_multiprocessing_main_handling.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:1st1,项目名称:cpython,代码行数:10,代码来源:test_compileall.py
示例9: 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:rayeya,项目名称:cpython,代码行数:10,代码来源: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:1st1,项目名称:cpython,代码行数:11,代码来源:test_compileall.py
示例11: 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:rayeya,项目名称:cpython,代码行数:11,代码来源:test_compileall.py
示例12: test_pyc_invalidation_mode
def test_pyc_invalidation_mode(self):
script_helper.make_script(self.pkgdir, 'f1', '')
pyc = importlib.util.cache_from_source(
os.path.join(self.pkgdir, 'f1.py'))
self.assertRunOK('--invalidation-mode=checked-hash', self.pkgdir)
with open(pyc, 'rb') as fp:
data = fp.read()
self.assertEqual(int.from_bytes(data[4:8], 'little'), 0b11)
self.assertRunOK('--invalidation-mode=unchecked-hash', self.pkgdir)
with open(pyc, 'rb') as fp:
data = fp.read()
self.assertEqual(int.from_bytes(data[4:8], 'little'), 0b01)
开发者ID:1st1,项目名称:cpython,代码行数: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:1st1,项目名称:cpython,代码行数: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:rayeya,项目名称:cpython,代码行数:12,代码来源:test_compileall.py
示例15: 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:rayeya,项目名称:cpython,代码行数:12,代码来源:test_compileall.py
示例16: 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:1st1,项目名称:cpython,代码行数:12,代码来源:test_compileall.py
示例17: 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:rayeya,项目名称:cpython,代码行数:13,代码来源:test_compileall.py
示例18: 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:1st1,项目名称:cpython,代码行数:13,代码来源:test_compileall.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:rayeya,项目名称:cpython,代码行数: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:10sr,项目名称:cpython,代码行数:7,代码来源:test_compileall.py
注:本文中的test.support.script_helper.make_script函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论