本文整理汇总了Python中test.support.script_helper.make_script函数的典型用法代码示例。如果您正苦于以下问题:Python make_script函数的具体用法?Python make_script怎么用?Python make_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_script函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)
示例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)
示例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')
示例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', '')
示例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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)