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


Python test_support.rmtree函数代码示例

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


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

示例1: _inside_empty_temp_dir

def _inside_empty_temp_dir():
    dir = tempfile.mkdtemp()
    try:
        with support.swap_attr(tempfile, 'tempdir', dir):
            yield
    finally:
        support.rmtree(dir)
开发者ID:Kelauni22,项目名称:Meeple,代码行数:7,代码来源:test_tempfile.py

示例2: tearDown

 def tearDown(self):
     sys.path[:] = self.sys_path
     if self.orig_module is not None:
         sys.modules[self.module_name] = self.orig_module
     else:
         unload(self.module_name)
     unlink(self.file_name)
     unlink(self.compiled_name)
     rmtree(self.dir_name)
开发者ID:MichaelBlume,项目名称:pypy,代码行数:9,代码来源:test_import.py

示例3: get_new_environment_path

def get_new_environment_path() :
    path=get_new_path("environment")
    import os
    try:
        os.makedirs(path,mode=0700)
    except os.error:
        test_support.rmtree(path)
        os.makedirs(path)
    return path
开发者ID:underrun,项目名称:pybsddb,代码行数:9,代码来源:test_all.py

示例4: check_script_output

 def check_script_output(self, src, expected):
     tmpd = tempfile.mkdtemp()
     try:
         fn = os.path.join(tmpd, 'test.py')
         with open(fn, 'wb') as fp:
             fp.write(src)
         rc, out, err = script_helper.assert_python_ok(fn)
     finally:
         rmtree(tmpd)
     self.assertEqual(out.rstrip(), expected)
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_source_encoding.py

示例5: create_modules

def create_modules(*names):
    u"""Temporarily create each named module with an attribute (named 'attr')
    that contains the name passed into the context manager that caused the
    creation of the module.

    All files are created in a temporary directory returned by
    tempfile.mkdtemp(). This directory is inserted at the beginning of
    sys.path. When the context manager exits all created files (source and
    bytecode) are explicitly deleted.

    No magic is performed when creating packages! This means that if you create
    a module within a package you must also create the package's __init__ as
    well.

    """
    source = u'attr = {0!r}'
    created_paths = []
    mapping = {}
    state_manager = None
    uncache_manager = None
    try:
        temp_dir = tempfile.mkdtemp()
        mapping[u'.root'] = temp_dir
        import_names = set()
        for name in names:
            if not name.endswith(u'__init__'):
                import_name = name
            else:
                import_name = name[:-len(u'.__init__')]
            import_names.add(import_name)
            if import_name in sys.modules:
                del sys.modules[import_name]
            name_parts = name.split(u'.')
            file_path = temp_dir
            for directory in name_parts[:-1]:
                file_path = os.path.join(file_path, directory)
                if not os.path.exists(file_path):
                    os.mkdir(file_path)
                    created_paths.append(file_path)
            file_path = os.path.join(file_path, name_parts[-1] + u'.py')
            with open(file_path, u'w') as file:
                file.write(source.format(name))
            created_paths.append(file_path)
            mapping[name] = file_path
        uncache_manager = util.uncache(*import_names)
        uncache_manager.__enter__()
        state_manager = util.import_state(path=[temp_dir])
        state_manager.__enter__()
        yield mapping
    finally:
        if state_manager is not None:
            state_manager.__exit__(None, None, None)
        if uncache_manager is not None:
            uncache_manager.__exit__(None, None, None)
        support.rmtree(temp_dir)
开发者ID:ralphbean,项目名称:importlib_full,代码行数:55,代码来源:util.py

示例6: test_yet_more_evil_still_undecodable

 def test_yet_more_evil_still_undecodable(self):
     # Issue #25388
     src = b"#\x00\n#\xfd\n"
     tmpd = tempfile.mkdtemp()
     try:
         fn = os.path.join(tmpd, "bad.py")
         with open(fn, "wb") as fp:
             fp.write(src)
         rc, out, err = script_helper.assert_python_failure(fn)
     finally:
         test_support.rmtree(tmpd)
     self.assertIn(b"Non-ASCII", err)
开发者ID:phamthanhnhan14,项目名称:redis_cluster_setup,代码行数:12,代码来源:test_compile.py

示例7: test_readonly_files

 def test_readonly_files(self):
     dir = _fname
     os.mkdir(dir)
     try:
         fname = os.path.join(dir, 'db')
         f = dumbdbm.open(fname, 'n')
         self.assertEqual(list(f.keys()), [])
         for key in self._dict:
             f[key] = self._dict[key]
         f.close()
         os.chmod(fname + ".dir", stat.S_IRUSR)
         os.chmod(fname + ".dat", stat.S_IRUSR)
         os.chmod(dir, stat.S_IRUSR|stat.S_IXUSR)
         f = dumbdbm.open(fname, 'r')
         self.assertEqual(sorted(f.keys()), sorted(self._dict))
         f.close()  # don't write
     finally:
         test_support.rmtree(dir)
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_dumbdbm.py

示例8: test_yet_more_evil_still_undecodable

 def test_yet_more_evil_still_undecodable(self):
     # Issue #25388
     src = b"#\x00\n#\xfd\n"
     tmpd = tempfile.mkdtemp()
     try:
         fn = os.path.join(tmpd, "bad.py")
         with open(fn, "wb") as fp:
             fp.write(src)
         try:
             rc, out, err = script_helper.assert_python_failure(fn)
         except AssertionError:
             if check_impl_detail(pypy=True):
                 # as long as we don't crash
                 return
             raise
     finally:
         test_support.rmtree(tmpd)
     self.assertIn(b"Non-ASCII", err)
开发者ID:mozillazg,项目名称:pypy,代码行数:18,代码来源:test_compile.py

示例9: test_security

 def test_security(self):
     # This test is incomplete since we are normally not run as root and
     # therefore can't test the file ownership being wrong.
     os.unlink(temp_filename)
     d = test_support.TESTFN
     try:
         os.mkdir(d)
         fn = os.path.join(d, '.netrc')
         with open(fn, 'wt') as f:
             f.write(TEST_NETRC)
         with test_support.EnvironmentVarGuard() as environ:
             environ.set('HOME', d)
             os.chmod(fn, 0600)
             self.netrc = netrc.netrc()
             self.test_case_1()
             os.chmod(fn, 0622)
             self.assertRaises(netrc.NetrcParseError, netrc.netrc)
     finally:
         test_support.rmtree(d)
开发者ID:exodrifter,项目名称:unity-python,代码行数:19,代码来源:test_netrc.py

示例10: tearDown

 def tearDown(self):
     rmtree(TESTFN)
     unlink(TESTFN)
开发者ID:0xcc,项目名称:python-read,代码行数:3,代码来源:test_trace.py

示例11: newdirinpath

 def newdirinpath(dir):
     os.mkdir(dir)
     sys.path.insert(0, dir)
     yield
     sys.path.pop(0)
     rmtree(dir)
开发者ID:andrcmdr,项目名称:unladen-swallow,代码行数:6,代码来源:test_pydoc.py

示例12: tearDown

 def tearDown(self):
     test_support.rmtree(self.tmpdir)
开发者ID:Stewori,项目名称:jython,代码行数:2,代码来源:test_bytecodetools_jy.py

示例13: remove_test_path_directory

def remove_test_path_directory() :
    test_support.rmtree(get_new_path.prefix)
开发者ID:underrun,项目名称:pybsddb,代码行数:2,代码来源:test_all.py

示例14: tearDown

 def tearDown(self):
     rmtree(self.topdir)
开发者ID:thinhnd8752,项目名称:junkcode,代码行数:2,代码来源:test_rpm.py

示例15: tearDownClass

 def tearDownClass(cls):
     td = cls.tmpdir
     if td and os.path.isdir(td):
         test_support.rmtree(td)
开发者ID:jythontools,项目名称:jython,代码行数:4,代码来源:test_import_jy.py


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