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


Python test_support.rmdir方法代码示例

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


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

示例1: test_usable_template

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import rmdir [as 别名]
def test_usable_template(self):
        # gettempprefix returns a usable prefix string

        # Create a temp directory, avoiding use of the prefix.
        # Then attempt to create a file whose name is
        # prefix + 'xxxxxx.xxx' in that directory.
        p = tempfile.gettempprefix() + "xxxxxx.xxx"
        d = tempfile.mkdtemp(prefix="")
        try:
            p = os.path.join(d, p)
            try:
                fd = os.open(p, os.O_RDWR | os.O_CREAT)
            except:
                self.failOnException("os.open")
            os.close(fd)
            os.unlink(p)
        finally:
            os.rmdir(d) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:20,代码来源:test_tempfile.py

示例2: test_mode

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import rmdir [as 别名]
def test_mode(self):
        # mkdtemp creates directories with the proper mode
        if not has_stat:
            return            # ugh, can't use TestSkipped.
        if support.is_jython and not os._native_posix:
            # Java doesn't support stating files for permissions
            return

        dir = self.do_create()
        try:
            mode = stat.S_IMODE(os.stat(dir).st_mode)
            mode &= 0777 # Mask off sticky bits inherited from /tmp
            expected = 0700
            if (sys.platform in ('win32', 'os2emx', 'mac') or
                support.is_jython and os._name == 'nt'):
                # There's no distinction among 'user', 'group' and 'world';
                # replicate the 'user' bits.
                user = expected >> 6
                expected = user * (1 + 8 + 64)
            self.assertEqual(mode, expected)
        finally:
            os.rmdir(dir) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:24,代码来源:test_tempfile.py

示例3: test_has_no_name

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import rmdir [as 别名]
def test_has_no_name(self):
        # TemporaryFile creates files with no names (on this system)
        dir = tempfile.mkdtemp()
        f = tempfile.TemporaryFile(dir=dir)
        f.write('blat')

        # Sneaky: because this file has no name, it should not prevent
        # us from removing the directory it was created in.
        try:
            os.rmdir(dir)
        except:
            ei = sys.exc_info()
            # cleanup
            f.close()
            os.rmdir(dir)
            self.failOnException("rmdir", ei) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:18,代码来源:test_tempfile.py

示例4: tearDown

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import rmdir [as 别名]
def tearDown(self):
        map(os.unlink, self._msgfiles)
        test_support.rmdir(os.path.join(self._dir, "cur"))
        test_support.rmdir(os.path.join(self._dir, "tmp"))
        test_support.rmdir(os.path.join(self._dir, "new"))
        test_support.rmdir(self._dir) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_mailbox.py

示例5: test_choose_directory

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import rmdir [as 别名]
def test_choose_directory(self):
        # _mkstemp_inner can create files in a user-selected directory
        dir = tempfile.mkdtemp()
        try:
            self.do_create(dir=dir).write("blat")
        finally:
            os.rmdir(dir)

    # XXX: Jython can't set the write mode yet 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:11,代码来源:test_tempfile.py

示例6: test_case_sensitive

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import rmdir [as 别名]
def test_case_sensitive(self):
        # gettempdir should not flatten its case
        # even on a case-insensitive file system
        # See CPython Issue 14255 (back-ported for Jython)
        case_sensitive_tempdir = tempfile.mkdtemp("-Temp")
        _tempdir, tempfile.tempdir = tempfile.tempdir, None
        try:
            with support.EnvironmentVarGuard() as env:
                # Fake the first env var which is checked as a candidate
                env["TMPDIR"] = case_sensitive_tempdir
                self.assertEqual(tempfile.gettempdir(), case_sensitive_tempdir)
        finally:
            tempfile.tempdir = _tempdir
            support.rmdir(case_sensitive_tempdir) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:16,代码来源:test_tempfile.py

示例7: do_create

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import rmdir [as 别名]
def do_create(self, dir=None, pre="", suf=""):
        if dir is None:
            dir = tempfile.gettempdir()
        try:
            name = tempfile.mkdtemp(dir=dir, prefix=pre, suffix=suf)
        except:
            self.failOnException("mkdtemp")

        try:
            self.nameCheck(name, dir, pre, suf)
            return name
        except:
            os.rmdir(name)
            raise 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:16,代码来源:test_tempfile.py

示例8: test_basic_many

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import rmdir [as 别名]
def test_basic_many(self):
        # mkdtemp can create many directories (stochastic)
        extant = range(TEST_FILES)
        try:
            for i in extant:
                extant[i] = self.do_create(pre="aa")
        finally:
            for i in extant:
                if(isinstance(i, basestring)):
                    os.rmdir(i) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:12,代码来源:test_tempfile.py

示例9: tearDown

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import rmdir [as 别名]
def tearDown(self):
        if self.dir:
            os.rmdir(self.dir)
            self.dir = None 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:6,代码来源:test_tempfile.py

示例10: test_del_on_close

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import rmdir [as 别名]
def test_del_on_close(self):
        # A NamedTemporaryFile is deleted when closed
        dir = tempfile.mkdtemp()
        try:
            f = tempfile.NamedTemporaryFile(dir=dir)
            f.write('blat')
            f.close()
            self.assertFalse(os.path.exists(f.name),
                        "NamedTemporaryFile %s exists after close" % f.name)
        finally:
            os.rmdir(dir) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:13,代码来源:test_tempfile.py


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