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


Python FilePath.touch方法代码示例

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


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

示例1: wrapper

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import touch [as 别名]
 def wrapper(case, *args, **kwargs):
     test_file = FilePath(case.mktemp())
     test_file.touch()
     test_file.chmod(0o000)
     permissions = test_file.getPermissions()
     test_file.chmod(0o777)
     if permissions != Permissions(0o000):
         raise SkipTest("Can't run test on filesystem with broken permissions.")
     return test_method(case, *args, **kwargs)
开发者ID:WUMUXIAN,项目名称:flocker,代码行数:11,代码来源:__init__.py

示例2: _testNonDirectoryChildEntry

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import touch [as 别名]
 def _testNonDirectoryChildEntry(self):
     path = FilePath(self.mktemp())
     self.failIf(path.exists())
     path.touch()
     child = path.child("test_package").path
     plugins.__path__.append(child)
     try:
         plgs = list(plugin.getPlugins(plugin.ITestPlugin))
         self.assertEqual(len(plgs), 1)
     finally:
         plugins.__path__.remove(child)
开发者ID:mrader11,项目名称:vodafone-mobile-connect,代码行数:13,代码来源:test_plugin.py

示例3: test_nonDirectoryChildEntry

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import touch [as 别名]
 def test_nonDirectoryChildEntry(self):
     """
     Test that getCache skips over any entries in a plugin package's
     C{__path__} which refer to children of paths which are not directories.
     """
     path = FilePath(self.mktemp())
     self.failIf(path.exists())
     path.touch()
     child = path.child("test_package").path
     self.module.__path__.append(child)
     try:
         plgs = list(plugin.getPlugins(ITestPlugin, self.module))
         self.assertEqual(len(plgs), 1)
     finally:
         self.module.__path__.remove(child)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:17,代码来源:test_plugin.py

示例4: test_runnerDebuggerDefaultsToPdb

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import touch [as 别名]
    def test_runnerDebuggerDefaultsToPdb(self):
        """
        Trial uses pdb if no debugger is specified by `--debugger`
        """
        self.parseOptions(['--debug', 'twisted.trial.test.sample'])
        pdbrcFile = FilePath("pdbrc")
        pdbrcFile.touch()

        self.runcall_called = False
        def runcall(pdb, suite, result):
            self.runcall_called = True
        self.patch(pdb.Pdb, "runcall", runcall)

        self.runSampleSuite(self.getRunner())

        self.assertTrue(self.runcall_called)
开发者ID:esabelhaus,项目名称:secret-octo-dubstep,代码行数:18,代码来源:test_runner.py

示例5: OptionsTests

# 需要导入模块: from twisted.python.filepath import FilePath [as 别名]
# 或者: from twisted.python.filepath.FilePath import touch [as 别名]
class OptionsTests(unittest.TestCase):
    """
    Tests for L{txghbot._api.Options}
    """
    def setUp(self):
        self.secretFilePath = self.mktemp()
        self.secretFile = FilePath(self.secretFilePath)
        self.secretFromPathOption = "--secret-from-path={}".format(
            self.secretFilePath)

        self.stringEnviron = {}
        self.bytesEnviron = {}

        self.osModuleFake = _FakeOSModule.fromdicts(self.stringEnviron,
                                                    self.bytesEnviron)

        self.config = Options(self.osModuleFake)

    def tearDown(self):
        if self.secretFile.exists():
            self.secretFile.remove()

    def secretFromEnvironmentOption(self, variable):
        """
        Generate the secret from environment variable command line
        option.

        @type variable: L{str}
        @param variable: The variable name

        @return: The formatted option containing the path.
        @rtype: L{str}
        """
        return "--secret-from-env={}".format(variable)

    def test_retrieveSecretFromEmptyPath(self):
        """
        An empty secret file raises an L{OSError}
        """
        self.secretFile.touch()
        exc = self.assertRaises(
            UsageError,
            self.config.parseOptions, [self.secretFromPathOption],
        )
        self.assertIn("empty", str(exc).lower())

    def test_retrieveSecretFromMissingPath(self):
        """
        An missing secret file raises an L{IOError}
        """
        self.assertRaises(
            IOError,
            self.config.parseOptions, [self.secretFromPathOption],
        )

    def test_retrieveSecretFromPath(self):
        """
        A newline-stripped secret is returned.  Internal whitespace is
        preserved.
        """
        with self.secretFile.open('wb') as f:
            f.write(b" this is a secret \r\n")
        self.config.parseOptions([self.secretFromPathOption])

        self.assertEqual(self.config["secret"], b" this is a secret ")

    def test_retrieveSecretFromEmptyEnvironment(self):
        """
        A L{UsageError} is raised when attempting to retrieve a secret
        from an environment that doesn't contain the provided
        variable.
        """

        self.assertRaises(UsageError,
                          self.config.parseOptions,
                          [self.secretFromEnvironmentOption("MISSING")])

    def test_retrieveSecretFromEnvironment(self):
        """
        The secret is retrieved as bytes from the process'
        environment.
        """
        self.bytesEnviron[b"SECRET"] = b"a secret"
        self.stringEnviron["SECRET"] = "a secret"

        self.config.parseOptions([self.secretFromEnvironmentOption("SECRET")])

        self.assertEqual(self.config["secret"], b"a secret")

    def test_missingSecret(self):
        """
        Omitting both a secret path and a secret environment variable
        name results in a L{UsageError}.
        """
        self.assertRaises(UsageError, self.config.parseOptions, [])

    def test_bothSecrets(self):
        """
        Including both a secret path and a secret environment variable
        name results in a L{UsageError}.
#.........这里部分代码省略.........
开发者ID:markrwilliams,项目名称:txghbot,代码行数:103,代码来源:test_api.py


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