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


Python testlib.temporaryPath函数代码示例

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


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

示例1: testSmallWrites

    def testSmallWrites(self):
        data = """
        Aliquet habitasse tellus. Fringilla faucibus tortor parturient
        consectetuer sodales, venenatis platea habitant. Hendrerit nostra nunc
        odio. Primis porttitor consequat enim ridiculus. Taciti nascetur,
        nibh, convallis sit, cum dis mi. Nonummy justo odio cursus, ac hac
        curabitur nibh. Tellus. Montes, ut taciti orci ridiculus facilisis
        nunc. Donec. Risus adipiscing habitant donec vehicula non vitae class,
        porta vitae senectus. Nascetur felis laoreet integer, tortor ligula.
        Pellentesque vestibulum cras nostra. Ut sollicitudin posuere, per
        accumsan curabitur id, nisi fermentum vel, eget netus tristique per,
        donec, curabitur senectus ut fusce. A. Mauris fringilla senectus et
        eni facilisis magna inceptos eu, cursus habitant fringilla neque.
        Nibh. Elit facilisis sed, elit, nostra ve torquent dictumst, aenean
        sapien quam, habitasse in. Eu tempus aptent, diam, nisi risus
        pharetra, ac, condimentum orci, consequat mollis. Cras lacus augue
        ultrices proin fermentum nibh sed urna. Ve ipsum ultrices curae,
        feugiat faucibus proin et elementum vivamus, lectus. Torquent. Tempus
        facilisi. Cras suspendisse euismod consectetuer ornare nostra. Fusce
        amet cum amet diam.
        """
        self.assertTrue(len(data) > 512)

        with temporaryPath() as srcPath:
            with fileUtils.open_ex(srcPath, "dw") as f:
                f.write(data[:512])
                f.write(data[512:])

            with fileUtils.open_ex(srcPath, "r") as f:
                self.assertEquals(f.read(len(data)), data)
开发者ID:Caez83,项目名称:vdsm,代码行数:30,代码来源:fileUtilTests.py

示例2: testCopyUserModeToGroup

 def testCopyUserModeToGroup(self):
     with temporaryPath() as path:
         for initialMode, expectedMode in self.modesList:
             os.chmod(path, initialMode)
             fileUtils.copyUserModeToGroup(path)
             self.assertEquals(os.stat(path).st_mode & self.MODE_MASK,
                               expectedMode)
开发者ID:yingyun001,项目名称:vdsm,代码行数:7,代码来源:fileUtilTests.py

示例3: testUpdateRead

    def testUpdateRead(self):
        data = """
        Aliquet. Aliquam eni ac nullam iaculis cras ante, adipiscing. Enim
        eget egestas pretium. Ultricies. Urna cubilia in, hac. Curabitur.
        Nibh. Purus ridiculus natoque sed id. Feugiat lacus quam, arcu
        maecenas nec egestas. Hendrerit duis nunc eget dis lacus porttitor per
        sodales class diam condimentum quisque condimentum nisi ligula.
        Dapibus blandit arcu nam non ac feugiat diam, dictumst. Ante eget
        fames eu penatibus in, porta semper accumsan adipiscing tellus in
        sagittis. Est parturient parturient mi fermentum commodo, per
        fermentum. Quis duis velit at quam risus mi. Facilisi id fames.
        Turpis, conubia rhoncus. Id. Elit eni tellus gravida, ut, erat morbi.
        Euismod, enim a ante vestibulum nibh. Curae curae primis vulputate
        adipiscing arcu ipsum suspendisse quam hymenaeos primis accumsan
        vestibulum.
        """
        self.assertTrue(len(data) > 512)

        with temporaryPath() as srcPath:
            with fileUtils.open_ex(srcPath, "wd") as f:
                f.write(data[:512])

            with fileUtils.open_ex(srcPath, "r+d") as f:
                f.seek(512)
                f.write(data[512:])

            with fileUtils.open_ex(srcPath, "r") as f:
                self.assertEquals(f.read(len(data)), data)
开发者ID:Caez83,项目名称:vdsm,代码行数:28,代码来源:fileUtilTests.py

示例4: test_small_writes

    def test_small_writes(self):
        with temporaryPath() as srcPath, directio.DirectFile(srcPath, "w") as f:
            f.write(self.DATA[:BLOCK_SIZE])
            f.write(self.DATA[BLOCK_SIZE:])

            with io.open(srcPath, "rb") as f:
                self.assertEquals(f.read(), self.DATA)
开发者ID:yingyun001,项目名称:vdsm,代码行数:7,代码来源:storage_directio_test.py

示例5: fake_dd

def fake_dd(delay):
    script = "#!/bin/sh\nsleep %.1f\n" % delay
    script = script.encode('ascii')
    with temporaryPath(data=script) as fake_dd:
        os.chmod(fake_dd, 0o700)
        with MonkeyPatchScope([(constants, "EXT_DD", fake_dd)]):
            yield
开发者ID:yingyun001,项目名称:vdsm,代码行数:7,代码来源:storage_check_test.py

示例6: testRead

 def testRead(self):
     data = """Vestibulum. Libero leo nostra, pede nunc eu. Pellentesque
     platea lacus morbi nisl montes ve. Ac. A, consectetuer erat, justo eu.
     Elementum et, phasellus fames et rutrum donec magnis eu bibendum. Arcu,
     ante aliquam ipsum ut facilisis ad."""
     with temporaryPath(data=data) as srcPath, \
             fileUtils.open_ex(srcPath, "dr") as f:
         self.assertEquals(f.read(), data)
开发者ID:kanalun,项目名称:vdsm,代码行数:8,代码来源:fileUtilTests.py

示例7: test_write_domxml

    def test_write_domxml(self, monkeypatch):
        with temporaryPath() as path:
            monkeypatch.setenv('_hook_domxml', path)
            hooking.write_domxml(minidom.parseString(self._EXPECTED_XML))

            with io.open(path, 'r') as src:
                found_xml = src.read()
        assert xml_equal(found_xml, self._EXPECTED_XML)
开发者ID:nirs,项目名称:vdsm,代码行数:8,代码来源:hooking_test.py

示例8: test_taskset_missing

 def test_taskset_missing(self):
     self.checks = 1
     with temporaryPath(data=b"blah") as path:
         checker = check.DirectioChecker(self.loop, path, self.complete)
         checker.start()
         self.loop.run_forever()
         pprint.pprint(self.results)
         result = self.results[0]
         self.assertRaises(exception.MiscFileReadException, result.delay)
开发者ID:yingyun001,项目名称:vdsm,代码行数:9,代码来源:storage_check_test.py

示例9: test_roundtrip_domxml

    def test_roundtrip_domxml(self, monkeypatch):
        with temporaryPath() as path:
            os.environ['_hook_domxml'] = path
            monkeypatch.setenv('_hook_domxml', path)

            hooking.write_domxml(minidom.parseString(self._EXPECTED_XML))
            domxml = hooking.read_domxml()

        assert xml_equal(domxml.toprettyxml(), self._EXPECTED_XML)
开发者ID:nirs,项目名称:vdsm,代码行数:9,代码来源:hooking_test.py

示例10: testWrite

 def testWrite(self):
     data = """In ut non platea egestas, quisque magnis nunc nostra ac etiam
     suscipit nec integer sociosqu. Fermentum. Ante orci luctus, ipsum
     ullamcorper enim arcu class neque inceptos class. Ut, sagittis
     torquent, commodo facilisi."""
     with temporaryPath() as srcPath, fileUtils.open_ex(srcPath, "dw") as f:
         f.write(data)
         with fileUtils.open_ex(srcPath, "r") as f:
             self.assertEquals(f.read(len(data)), data)
开发者ID:kanalun,项目名称:vdsm,代码行数:9,代码来源:fileUtilTests.py

示例11: test_allocate

 def test_allocate(self, image_format, allocation_mode, allocated_bytes):
     size = 16 * 1024 * 1024
     with temporaryPath() as image:
         op = qemuimg.create(image,
                             size=size,
                             format=image_format,
                             preallocation=allocation_mode)
         op.run()
         allocated = os.stat(image).st_blocks * 512
         assert allocated == allocated_bytes
开发者ID:nirs,项目名称:vdsm,代码行数:10,代码来源:qemuimg_test.py

示例12: test_update_and_read

    def test_update_and_read(self):
        with temporaryPath() as srcPath, directio.DirectFile(srcPath, "w") as f:
            f.write(self.DATA[:BLOCK_SIZE])

            with directio.DirectFile(srcPath, "r+") as f:
                f.seek(BLOCK_SIZE)
                f.write(self.DATA[BLOCK_SIZE:])

            with io.open(srcPath, "rb") as f:
                self.assertEquals(f.read(), self.DATA)
开发者ID:yingyun001,项目名称:vdsm,代码行数:10,代码来源:storage_directio_test.py

示例13: env

def env(enable='true', format='pstat', clock='cpu', builtins='false'):
    with temporaryPath() as filename:
        config = make_config([
            ('devel', 'cpu_profile_enable', enable),
            ('devel', 'cpu_profile_filename', filename),
            ('devel', 'cpu_profile_format', format),
            ('devel', 'cpu_profile_clock', clock),
            ('devel', 'cpu_profile_builtins', builtins),
        ])
        with MonkeyPatchScope([(cpu, 'config', config)]):
            yield filename
开发者ID:nirs,项目名称:vdsm,代码行数:11,代码来源:cpu_profile_test.py

示例14: test_path_ok

 def test_path_ok(self):
     self.checks = 1
     with temporaryPath(data=b"blah") as path:
         checker = check.DirectioChecker(self.loop, path, self.complete)
         checker.start()
         self.loop.run_forever()
         pprint.pprint(self.results)
         result = self.results[0]
         delay = result.delay()
         print("delay:", delay)
         self.assertEqual(type(delay), float)
开发者ID:yingyun001,项目名称:vdsm,代码行数:11,代码来源:storage_check_test.py

示例15: testNames

    def testNames(self):
        # I convert to some id because I have no
        # idea what users are defined and what
        # there IDs are apart from root
        tmpId = 666
        with temporaryPath() as srcPath:
            fileUtils.chown(srcPath, tmpId, tmpId)
            stat = os.stat(srcPath)
            self.assertTrue(stat.st_uid == stat.st_gid == tmpId)

            fileUtils.chown(srcPath, "root", "root")
            stat = os.stat(srcPath)
            self.assertTrue(stat.st_uid == stat.st_gid == 0)
开发者ID:yingyun001,项目名称:vdsm,代码行数:13,代码来源:fileUtilTests.py


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