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


Python ManifestParser.write方法代码示例

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


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

示例1: test_parent_inheritance

# 需要导入模块: from manifestparser import ManifestParser [as 别名]
# 或者: from manifestparser.ManifestParser import write [as 别名]
    def test_parent_inheritance(self):
        """
        Test parent manifest variable inheritance
        Specifically tests that inherited variables from parent includes
        properly propagate downstream
        """
        parent_example = os.path.join(here, 'parent', 'level_1', 'level_2',
                                      'level_3', 'level_3.ini')
        parser = ManifestParser(manifests=(parent_example,))

        # Parent manifest test should not be included
        self.assertEqual(parser.get('name'),
                         ['test_3'])
        self.assertEqual([(test['name'], os.path.basename(test['manifest']))
                          for test in parser.tests],
                         [('test_3', 'level_3.ini')])

        # DEFAULT values should be the ones from level 1
        self.assertEqual(parser.get('name', x='level_1'),
                         ['test_3'])

        # Write the output to a manifest:
        buffer = StringIO()
        parser.write(fp=buffer, global_kwargs={'x': 'level_1'})
        self.assertEqual(buffer.getvalue().strip(),
                         '[DEFAULT]\nx = level_1\n\n[test_3]\nsubsuite =')
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:28,代码来源:test_manifestparser.py

示例2: test_include

# 需要导入模块: from manifestparser import ManifestParser [as 别名]
# 或者: from manifestparser.ManifestParser import write [as 别名]
    def test_include(self):
        """Illustrate how include works"""

        include_example = os.path.join(here, 'include-example.ini')
        parser = ManifestParser(manifests=(include_example,))

        # All of the tests should be included, in order:
        self.assertEqual(parser.get('name'),
                         ['crash-handling', 'fleem', 'flowers'])
        self.assertEqual([(test['name'], os.path.basename(test['manifest'])) for test in parser.tests],
                         [('crash-handling', 'bar.ini'), ('fleem', 'include-example.ini'), ('flowers', 'foo.ini')])


        # The manifests should be there too:
        self.assertEqual(len(parser.manifests()), 3)

        # We already have the root directory:
        self.assertEqual(here, parser.rootdir)


        # DEFAULT values should persist across includes, unless they're
        # overwritten.  In this example, include-example.ini sets foo=bar, but
        # it's overridden to fleem in bar.ini
        self.assertEqual(parser.get('name', foo='bar'),
                         ['fleem', 'flowers'])
        self.assertEqual(parser.get('name', foo='fleem'),
                         ['crash-handling'])

        # Passing parameters in the include section allows defining variables in
        #the submodule scope:
        self.assertEqual(parser.get('name', tags=['red']),
                         ['flowers'])

        # However, this should be overridable from the DEFAULT section in the
        # included file and that overridable via the key directly connected to
        # the test:
        self.assertEqual(parser.get(name='flowers')[0]['blue'],
                         'ocean')
        self.assertEqual(parser.get(name='flowers')[0]['yellow'],
                         'submarine')

        # You can query multiple times if you need to:
        flowers = parser.get(foo='bar')
        self.assertEqual(len(flowers), 2)

        # Using the inverse flag should invert the set of tests returned:
        self.assertEqual(parser.get('name', inverse=True, tags=['red']),
                         ['crash-handling', 'fleem'])

        # All of the included tests actually exist:
        self.assertEqual([i['name'] for i in parser.missing()], [])

        # Write the output to a manifest:
        buffer = StringIO()
        parser.write(fp=buffer, global_kwargs={'foo': 'bar'})
        self.assertEqual(buffer.getvalue().strip(),
                         '[DEFAULT]\nfoo = bar\n\n[fleem]\n\n[include/flowers]\nblue = ocean\nred = roses\nyellow = submarine')
开发者ID:AutomatedTester,项目名称:mozbase,代码行数:59,代码来源:test_manifestparser.py

示例3: test_parent_defaults

# 需要导入模块: from manifestparser import ManifestParser [as 别名]
# 或者: from manifestparser.ManifestParser import write [as 别名]
    def test_parent_defaults(self):
        """
        Test downstream variables should overwrite upstream variables
        """
        parent_example = os.path.join(here, "parent", "level_1", "level_2", "level_3", "level_3_default.ini")
        parser = ManifestParser(manifests=(parent_example,))

        # Parent manifest test should not be included
        self.assertEqual(parser.get("name"), ["test_3"])
        self.assertEqual(
            [(test["name"], os.path.basename(test["manifest"])) for test in parser.tests],
            [("test_3", "level_3_default.ini")],
        )

        # DEFAULT values should be the ones from level 3
        self.assertEqual(parser.get("name", x="level_3"), ["test_3"])

        # Write the output to a manifest:
        buffer = StringIO()
        parser.write(fp=buffer, global_kwargs={"x": "level_3"})
        self.assertEqual(buffer.getvalue().strip(), "[DEFAULT]\nx = level_3\n\n[test_3]")
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:23,代码来源:test_manifestparser.py

示例4: test_parent_inheritance

# 需要导入模块: from manifestparser import ManifestParser [as 别名]
# 或者: from manifestparser.ManifestParser import write [as 别名]
    def test_parent_inheritance(self):
        """
        Test parent manifest variable inheritance
        Specifically tests that inherited variables from parent includes
        properly propagate downstream
        """
        parent_example = os.path.join(here, "parent", "level_1", "level_2", "level_3", "level_3.ini")
        parser = ManifestParser(manifests=(parent_example,))

        # Parent manifest test should not be included
        self.assertEqual(parser.get("name"), ["test_3"])
        self.assertEqual(
            [(test["name"], os.path.basename(test["manifest"])) for test in parser.tests], [("test_3", "level_3.ini")]
        )

        # DEFAULT values should be the ones from level 1
        self.assertEqual(parser.get("name", x="level_1"), ["test_3"])

        # Write the output to a manifest:
        buffer = StringIO()
        parser.write(fp=buffer, global_kwargs={"x": "level_1"})
        self.assertEqual(buffer.getvalue().strip(), "[DEFAULT]\nx = level_1\n\n[test_3]")
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:24,代码来源:test_manifestparser.py

示例5: test_parent_defaults

# 需要导入模块: from manifestparser import ManifestParser [as 别名]
# 或者: from manifestparser.ManifestParser import write [as 别名]
    def test_parent_defaults(self):
        """
        Test downstream variables should overwrite upstream variables
        """
        parent_example = os.path.join(here, 'parent', 'level_1', 'level_2',
                                      'level_3', 'level_3_default.ini')
        parser = ManifestParser(manifests=(parent_example,))

        # Parent manifest test should not be included
        self.assertEqual(parser.get('name'),
                         ['test_3'])
        self.assertEqual([(test['name'], os.path.basename(test['manifest'])) for test in parser.tests],
                         [('test_3', 'level_3_default.ini')])

        # DEFAULT values should be the ones from level 3
        self.assertEqual(parser.get('name', x='level_3'),
                         ['test_3'])

        # Write the output to a manifest:
        buffer = StringIO()
        parser.write(fp=buffer, global_kwargs={'x': 'level_3'})
        self.assertEqual(buffer.getvalue().strip(),
                         '[DEFAULT]\nx = level_3\n\n[test_3]\nsubsuite =')
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:25,代码来源:test_manifestparser.py

示例6: test_include

# 需要导入模块: from manifestparser import ManifestParser [as 别名]
# 或者: from manifestparser.ManifestParser import write [as 别名]
    def test_include(self):
        """Illustrate how include works"""

        include_example = os.path.join(here, "include-example.ini")
        parser = ManifestParser(manifests=(include_example,))

        # All of the tests should be included, in order:
        self.assertEqual(parser.get("name"), ["crash-handling", "fleem", "flowers"])
        self.assertEqual(
            [(test["name"], os.path.basename(test["manifest"])) for test in parser.tests],
            [("crash-handling", "bar.ini"), ("fleem", "include-example.ini"), ("flowers", "foo.ini")],
        )

        # The including manifest is always reported as a part of the generated test object.
        self.assertTrue(all([t["ancestor-manifest"] == include_example for t in parser.tests if t["name"] != "fleem"]))

        # The manifests should be there too:
        self.assertEqual(len(parser.manifests()), 3)

        # We already have the root directory:
        self.assertEqual(here, parser.rootdir)

        # DEFAULT values should persist across includes, unless they're
        # overwritten.  In this example, include-example.ini sets foo=bar, but
        # it's overridden to fleem in bar.ini
        self.assertEqual(parser.get("name", foo="bar"), ["fleem", "flowers"])
        self.assertEqual(parser.get("name", foo="fleem"), ["crash-handling"])

        # Passing parameters in the include section allows defining variables in
        # the submodule scope:
        self.assertEqual(parser.get("name", tags=["red"]), ["flowers"])

        # However, this should be overridable from the DEFAULT section in the
        # included file and that overridable via the key directly connected to
        # the test:
        self.assertEqual(parser.get(name="flowers")[0]["blue"], "ocean")
        self.assertEqual(parser.get(name="flowers")[0]["yellow"], "submarine")

        # You can query multiple times if you need to:
        flowers = parser.get(foo="bar")
        self.assertEqual(len(flowers), 2)

        # Using the inverse flag should invert the set of tests returned:
        self.assertEqual(parser.get("name", inverse=True, tags=["red"]), ["crash-handling", "fleem"])

        # All of the included tests actually exist:
        self.assertEqual([i["name"] for i in parser.missing()], [])

        # Write the output to a manifest:
        buffer = StringIO()
        parser.write(fp=buffer, global_kwargs={"foo": "bar"})
        expected_output = """[DEFAULT]
foo = bar

[fleem]

[include/flowers]
blue = ocean
red = roses
yellow = submarine"""  # noqa

        self.assertEqual(buffer.getvalue().strip(), expected_output)
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:64,代码来源:test_manifestparser.py


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