当前位置: 首页>>代码示例>>Python>>正文


Python script_helper.make_script方法代码示例

本文整理汇总了Python中test.script_helper.make_script方法的典型用法代码示例。如果您正苦于以下问题:Python script_helper.make_script方法的具体用法?Python script_helper.make_script怎么用?Python script_helper.make_script使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test.script_helper的用法示例。


在下文中一共展示了script_helper.make_script方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _ready_to_import

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
def _ready_to_import(name=None, source=""):
    # sets up a temporary directory and removes it
    # creates the module file
    # temporarily clears the module from sys.modules (if any)
    # reverts or removes the module when cleaning up
    name = name or "spam"
    with script_helper.temp_dir() as tempdir:
        path = script_helper.make_script(tempdir, name, source)
        old_module = sys.modules.pop(name, None)
        try:
            sys.path.insert(0, tempdir)
            yield name, path
            sys.path.remove(tempdir)
        finally:
            if old_module is not None:
                sys.modules[name] = old_module
            elif name in sys.modules:
                del sys.modules[name] 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:20,代码来源:test_import.py

示例2: test_import_in_del_does_not_crash

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
def test_import_in_del_does_not_crash(self):
        # Issue 4236
        testfn = script_helper.make_script('', TESTFN, textwrap.dedent("""\
            import sys
            class C:
               def __del__(self):
                  import imp
            sys.argv.insert(0, C())
            """))
        try:
            script_helper.assert_python_ok(testfn)
        finally:
            unlink(testfn) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_import.py

示例3: test_import_in_del_does_not_crash

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
def test_import_in_del_does_not_crash(self):
        # Issue 4236
        testfn = script_helper.make_script('', TESTFN, textwrap.dedent("""\
            import sys
            class C:
               def __del__(self):
                  import importlib
            sys.argv.insert(0, C())
            """))
        script_helper.assert_python_ok(testfn) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:12,代码来源:test_import.py

示例4: test_unencodable_filename

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
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')
        self.addCleanup(unlink, pyname)
        name = pyname[:-3]
        script_helper.assert_python_ok("-c", "mod = __import__(%a)" % name,
                                       __isolated=False) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:10,代码来源:test_import.py

示例5: setUp

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
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:IronLanguages,项目名称:ironpython3,代码行数:11,代码来源:test_compileall.py

示例6: test_no_args_compiles_path

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
def test_no_args_compiles_path(self):
        # Note that -l is implied for the no args case.
        self._skip_if_sys_path_not_writable()
        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:IronLanguages,项目名称:ironpython3,代码行数:10,代码来源:test_compileall.py

示例7: test_no_args_respects_quiet_flag

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
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)

    # Ensure that the default behavior of compileall's CLI is to create
    # PEP 3147 pyc/pyo files. 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:12,代码来源:test_compileall.py

示例8: test_recursion_control

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
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:IronLanguages,项目名称:ironpython3,代码行数:13,代码来源:test_compileall.py

示例9: test_multiple_dirs

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
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:IronLanguages,项目名称:ironpython3,代码行数:12,代码来源:test_compileall.py

示例10: test_d_compile_error

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
def test_d_compile_error(self):
        script_helper.make_script(self.pkgdir, 'crunchyfrog', 'bad(syntax')
        rc, out, err = self.assertRunNotOK('-q', '-d', 'dinsdale', self.pkgdir)
        self.assertRegex(out, b'File "dinsdale') 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:6,代码来源:test_compileall.py

示例11: test_d_runtime_error

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
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:IronLanguages,项目名称:ironpython3,代码行数:11,代码来源:test_compileall.py

示例12: test_include_file_no_arg

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
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:IronLanguages,项目名称:ironpython3,代码行数:14,代码来源:test_compileall.py

示例13: test_include_on_stdin

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
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:IronLanguages,项目名称:ironpython3,代码行数:14,代码来源:test_compileall.py

示例14: test_compiles_as_much_as_possible

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import make_script [as 别名]
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:IronLanguages,项目名称:ironpython3,代码行数:10,代码来源:test_compileall.py


注:本文中的test.script_helper.make_script方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。