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


Python support.temp_dir函数代码示例

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


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

示例1: test_consistent_sys_path_for_direct_execution

 def test_consistent_sys_path_for_direct_execution(self):
     # This test case ensures that the following all give the same
     # sys.path configuration:
     #
     #    ./python -s script_dir/__main__.py
     #    ./python -s script_dir
     #    ./python -I script_dir
     script = textwrap.dedent("""\
         import sys
         for entry in sys.path:
             print(entry)
         """)
     # Always show full path diffs on errors
     self.maxDiff = None
     with support.temp_dir() as work_dir, support.temp_dir() as script_dir:
         script_name = _make_test_script(script_dir, '__main__', script)
         # Reference output comes from directly executing __main__.py
         # We omit PYTHONPATH and user site to align with isolated mode
         p = spawn_python("-Es", script_name, cwd=work_dir)
         out_by_name = kill_python(p).decode().splitlines()
         self.assertEqual(out_by_name[0], script_dir)
         self.assertNotIn(work_dir, out_by_name)
         # Directory execution should give the same output
         p = spawn_python("-Es", script_dir, cwd=work_dir)
         out_by_dir = kill_python(p).decode().splitlines()
         self.assertEqual(out_by_dir, out_by_name)
         # As should directory execution in isolated mode
         p = spawn_python("-I", script_dir, cwd=work_dir)
         out_by_dir_isolated = kill_python(p).decode().splitlines()
         self.assertEqual(out_by_dir_isolated, out_by_dir, out_by_name)
开发者ID:Daetalus,项目名称:cpython,代码行数:30,代码来源:test_cmd_line_script.py

示例2: 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.assertRaisesRegex(RecursionError, msg, run_path, zip_name)
开发者ID:francois-wellenreiter,项目名称:cpython,代码行数:8,代码来源:test_runpy.py

示例3: test_script_compiled

 def test_script_compiled(self):
     with support.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:wdv4758h,项目名称:cpython,代码行数:7,代码来源:test_cmd_line_script.py

示例4: 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, mod_name=mod_name, check_loader=False)
开发者ID:francois-wellenreiter,项目名称:cpython,代码行数:7,代码来源:test_runpy.py

示例5: test_package_error

 def test_package_error(self):
     with support.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:wdv4758h,项目名称:cpython,代码行数:7,代码来源:test_cmd_line_script.py

示例6: test_basic_script_no_suffix

 def test_basic_script_no_suffix(self):
     with temp_dir() as script_dir:
         mod_name = 'script'
         script_name = self._make_test_script(script_dir, mod_name,
                                              omit_suffix=True)
         self._check_script(script_name, "<run_path>", script_name,
                            script_name, expect_spec=False)
开发者ID:DAWZayas-Projects,项目名称:TEJEDOR-RETUERTO-ALEJANDRO,代码行数:7,代码来源:test_runpy.py

示例7: 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 = py_compile.compile(script_name, doraise=True)
         os.remove(script_name)
         self._check_script(compiled_name, "<run_path>", compiled_name, compiled_name, expect_spec=False)
开发者ID:francois-wellenreiter,项目名称:cpython,代码行数:7,代码来源:test_runpy.py

示例8: test_zipfile

 def test_zipfile(self):
     with temp_dir() as script_dir:
         mod_name = '__main__'
         script_name = self._make_test_script(script_dir, mod_name)
         zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name)
         self._check_script(zip_name, "<run_path>", fname, zip_name,
                            mod_name=mod_name, check_loader=False)
开发者ID:DAWZayas-Projects,项目名称:TEJEDOR-RETUERTO-ALEJANDRO,代码行数:7,代码来源:test_runpy.py

示例9: 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:DAWZayas-Projects,项目名称:TEJEDOR-RETUERTO-ALEJANDRO,代码行数:7,代码来源:test_runpy.py

示例10: test_module_in_subpackage_in_zipfile

 def test_module_in_subpackage_in_zipfile(self):
     with support.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:CabbageHead-360,项目名称:cpython,代码行数:7,代码来源:test_cmd_line_script.py

示例11: test_zipfile

 def test_zipfile(self):
     source = self.main_in_children_source
     with support.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:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:7,代码来源:test_multiprocessing_main_handling.py

示例12: test_module_in_subpackage_in_zipfile

 def test_module_in_subpackage_in_zipfile(self):
     with support.temp_dir() as script_dir:
         zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script', depth=2)
         self._check_script(["-m", "test_pkg.test_pkg.script"], run_name, run_name,
                            script_dir, 'test_pkg.test_pkg',
                            zipimport.zipimporter,
                            PYTHONPATH=zip_name, cwd=script_dir)
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:7,代码来源:test_cmd_line_script.py

示例13: test_script_compiled

 def test_script_compiled(self):
     with support.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)
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:7,代码来源:test_multiprocessing_main_handling.py

示例14: test_ismount

    def test_ismount(self):
        self.assertTrue(ntpath.ismount("c:\\"))
        self.assertTrue(ntpath.ismount("C:\\"))
        self.assertTrue(ntpath.ismount("c:/"))
        self.assertTrue(ntpath.ismount("C:/"))
        self.assertTrue(ntpath.ismount("\\\\.\\c:\\"))
        self.assertTrue(ntpath.ismount("\\\\.\\C:\\"))

        self.assertTrue(ntpath.ismount(b"c:\\"))
        self.assertTrue(ntpath.ismount(b"C:\\"))
        self.assertTrue(ntpath.ismount(b"c:/"))
        self.assertTrue(ntpath.ismount(b"C:/"))
        self.assertTrue(ntpath.ismount(b"\\\\.\\c:\\"))
        self.assertTrue(ntpath.ismount(b"\\\\.\\C:\\"))

        with support.temp_dir() as d:
            self.assertFalse(ntpath.ismount(d))

        if sys.platform == "win32":
            #
            # Make sure the current folder isn't the root folder
            # (or any other volume root). The drive-relative
            # locations below cannot then refer to mount points
            #
            drive, path = ntpath.splitdrive(sys.executable)
            with support.change_cwd(os.path.dirname(sys.executable)):
                self.assertFalse(ntpath.ismount(drive.lower()))
                self.assertFalse(ntpath.ismount(drive.upper()))

            self.assertTrue(ntpath.ismount("\\\\localhost\\c$"))
            self.assertTrue(ntpath.ismount("\\\\localhost\\c$\\"))

            self.assertTrue(ntpath.ismount(b"\\\\localhost\\c$"))
            self.assertTrue(ntpath.ismount(b"\\\\localhost\\c$\\"))
开发者ID:venkatanagineni,项目名称:cpython,代码行数:34,代码来源:test_ntpath.py

示例15: test_package_error

 def test_package_error(self):
     with support.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")
         self._check_import_error(["-m", "test_pkg"], msg, cwd=script_dir)
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:7,代码来源:test_cmd_line_script.py


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