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


Python script_helper.temp_dir函数代码示例

本文整理汇总了Python中test.script_helper.temp_dir函数的典型用法代码示例。如果您正苦于以下问题:Python temp_dir函数的具体用法?Python temp_dir怎么用?Python temp_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: 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

示例2: test_directory_compiled

 def test_directory_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)
         os.remove(script_name)
         self._check_script(script_dir, "<run_path>", compiled_name, script_dir, "")
开发者ID:lzjun567,项目名称:python2.7,代码行数:7,代码来源:test_runpy.py

示例3: test_basic_script

 def test_basic_script(self):
     with temp_dir() as script_dir:
         script_name = _make_test_script(script_dir, 'script')
         package = '' if support.check_impl_detail(pypy=True) else None
         self._check_script(script_name, script_name, script_name,
                            script_dir, package,
                            importlib.machinery.SourceFileLoader)
开发者ID:timm,项目名称:timmnix,代码行数:7,代码来源:test_cmd_line_script.py

示例4: test_script_compiled

 def test_script_compiled(self):
     with temp_dir() as script_dir:
         mod_name = "script"
         script_name = self._make_test_script(script_dir, mod_name)
         compiled_name = compile_script(script_name)
         os.remove(script_name)
         self._check_script(compiled_name, "<run_path>", compiled_name, compiled_name, None)
开发者ID:lzjun567,项目名称:python2.7,代码行数:7,代码来源:test_runpy.py

示例5: 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

示例6: 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

示例7: 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

示例8: test_module_in_subpackage_in_zipfile

 def test_module_in_subpackage_in_zipfile(self):
     with temp_dir() as script_dir:
         zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script', depth=2)
         launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.test_pkg.script', zip_name)
         self._check_script(launch_name, run_name, run_name,
                            zip_name, 'test_pkg.test_pkg',
                            zipimport.zipimporter)
开发者ID:BeboPremo,项目名称:cpython,代码行数:7,代码来源:test_cmd_line_script.py

示例9: 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

示例10: test_module_in_package

 def test_module_in_package(self):
     with temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir)
         script_name = _make_test_script(pkg_dir, 'script')
         launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script')
         self._check_script(launch_name, script_name, script_name, 'test_pkg')
开发者ID:EnviroCentre,项目名称:jython-upgrade,代码行数:7,代码来源:test_cmd_line_script.py

示例11: test_package_error

 def test_package_error(self):
     with temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, "test_pkg")
         make_pkg(pkg_dir)
         msg = "'test_pkg' is a package and cannot " "be directly executed"
         launch_name = _make_launch_script(script_dir, "launch", "test_pkg")
         self._check_import_error(launch_name, msg)
开发者ID:hsienchieh,项目名称:uefilab,代码行数:7,代码来源:test_cmd_line_script.py

示例12: 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

示例13: test_package

 def test_package(self):
     with temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, "test_pkg")
         make_pkg(pkg_dir)
         script_name = _make_test_script(pkg_dir, "__main__")
         launch_name = _make_launch_script(script_dir, "launch", "test_pkg")
         self._check_script(launch_name, script_name, script_name, "test_pkg")
开发者ID:hsienchieh,项目名称:uefilab,代码行数:7,代码来源:test_cmd_line_script.py

示例14: test_script_compiled

 def test_script_compiled(self):
     with temp_dir() as script_dir:
         script_name = _make_test_script(script_dir, "script")
         py_compile.compile(script_name, doraise=True)
         os.remove(script_name)
         pyc_file = support.make_legacy_pyc(script_name)
         self._check_script(pyc_file, pyc_file, pyc_file, script_dir, None, importlib.machinery.SourcelessFileLoader)
开发者ID:GaloisInc,项目名称:echronos,代码行数:7,代码来源:test_cmd_line_script.py

示例15: 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


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