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


Python ManifestParser.update方法代码示例

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


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

示例1: test_update

# 需要导入模块: from manifestparser import ManifestParser [as 别名]
# 或者: from manifestparser.ManifestParser import update [as 别名]
    def test_update(self):
        """
        Test our ability to update tests from a manifest and a directory of
        files
        """

        # boilerplate
        tempdir = create_realpath_tempdir()
        for i in range(10):
            file(os.path.join(tempdir, str(i)), 'w').write(str(i))

        # otherwise empty directory with a manifest file
        newtempdir = create_realpath_tempdir()
        manifest_file = os.path.join(newtempdir, 'manifest.ini')
        manifest_contents = str(convert([tempdir], relative_to=tempdir))
        with file(manifest_file, 'w') as f:
            f.write(manifest_contents)

        # get the manifest
        manifest = ManifestParser(manifests=(manifest_file,))

        # All of the tests are initially missing:
        paths = [str(i) for i in range(10)]
        self.assertEqual([i['name'] for i in manifest.missing()],
                         paths)

        # But then we copy one over:
        self.assertEqual(manifest.get('name', name='1'), ['1'])
        manifest.update(tempdir, name='1')
        self.assertEqual(sorted(os.listdir(newtempdir)),
                        ['1', 'manifest.ini'])

        # Update that one file and copy all the "tests":
        file(os.path.join(tempdir, '1'), 'w').write('secret door')
        manifest.update(tempdir)
        self.assertEqual(sorted(os.listdir(newtempdir)),
                        ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'manifest.ini'])
        self.assertEqual(file(os.path.join(newtempdir, '1')).read().strip(),
                        'secret door')

        # clean up:
        shutil.rmtree(tempdir)
        shutil.rmtree(newtempdir)
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:45,代码来源:test_convert_directory.py

示例2: test_update

# 需要导入模块: from manifestparser import ManifestParser [as 别名]
# 或者: from manifestparser.ManifestParser import update [as 别名]
    def test_update(self):
        """
        Test our ability to update tests from a manifest and a directory of
        files
        """

        # boilerplate
        tempdir = tempfile.mkdtemp()
        for i in range(10):
            file(os.path.join(tempdir, str(i)), 'w').write(str(i))

        # First, make a manifest:
        manifest = convert([tempdir])
        newtempdir = tempfile.mkdtemp()
        manifest_file = os.path.join(newtempdir, 'manifest.ini')
        file(manifest_file,'w').write(manifest)
        manifest = ManifestParser(manifests=(manifest_file,))
        self.assertEqual(manifest.get('name'),
                         [str(i) for i in range(10)])

        # All of the tests are initially missing:
        self.assertEqual([i['name'] for i in manifest.missing()],
                         [str(i) for i in range(10)])

        # But then we copy one over:
        self.assertEqual(manifest.get('name', name='1'), ['1'])
        manifest.update(tempdir, name='1')
        self.assertEqual(sorted(os.listdir(newtempdir)),
                         ['1', 'manifest.ini'])

        # Update that one file and copy all the "tests":
        file(os.path.join(tempdir, '1'), 'w').write('secret door')
        manifest.update(tempdir)
        self.assertEqual(sorted(os.listdir(newtempdir)),
                         ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'manifest.ini'])
        self.assertEqual(file(os.path.join(newtempdir, '1')).read().strip(),
                         'secret door')

        # clean up:
        shutil.rmtree(tempdir)
        shutil.rmtree(newtempdir)
开发者ID:markrcote,项目名称:mozbase,代码行数:43,代码来源:test_manifestparser.py

示例3: test_update

# 需要导入模块: from manifestparser import ManifestParser [as 别名]
# 或者: from manifestparser.ManifestParser import update [as 别名]
    def test_update(self):
        """
        Test our ability to update tests from a manifest and a directory of
        files
        """

        # boilerplate
        tempdir = create_realpath_tempdir()
        for i in range(10):
            file(os.path.join(tempdir, str(i)), "w").write(str(i))

        # otherwise empty directory with a manifest file
        newtempdir = create_realpath_tempdir()
        manifest_file = os.path.join(newtempdir, "manifest.ini")
        manifest_contents = str(convert([tempdir], relative_to=tempdir))
        with file(manifest_file, "w") as f:
            f.write(manifest_contents)

        # get the manifest
        manifest = ManifestParser(manifests=(manifest_file,))

        # All of the tests are initially missing:
        paths = [str(i) for i in range(10)]
        self.assertEqual([i["name"] for i in manifest.missing()], paths)

        # But then we copy one over:
        self.assertEqual(manifest.get("name", name="1"), ["1"])
        manifest.update(tempdir, name="1")
        self.assertEqual(sorted(os.listdir(newtempdir)), ["1", "manifest.ini"])

        # Update that one file and copy all the "tests":
        file(os.path.join(tempdir, "1"), "w").write("secret door")
        manifest.update(tempdir)
        self.assertEqual(
            sorted(os.listdir(newtempdir)), ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "manifest.ini"]
        )
        self.assertEqual(file(os.path.join(newtempdir, "1")).read().strip(), "secret door")

        # clean up:
        shutil.rmtree(tempdir)
        shutil.rmtree(newtempdir)
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:43,代码来源:test_convert_directory.py


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