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


Python utils.wrap函数代码示例

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


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

示例1: test_parse_default

def test_parse_default():
    with wrap() as wrapper:
        wrapper.nodes = {}
        wrapper.roots = []
        wrapper.batch = dexy.batch.Batch(wrapper)
        wrapper.filemap = wrapper.map_files()

        ast = AbstractSyntaxTree(wrapper)
        parser = Yaml(wrapper, ast)
        parser.parse('.', YAML_WITH_DEFAULT_OFF)
        ast.walk()
        assert len(wrapper.nodes) == 0

    with wrap() as wrapper:
        wrapper.nodes = {}
        wrapper.roots = []
        wrapper.batch = dexy.batch.Batch(wrapper)
        wrapper.filemap = wrapper.map_files()

        ast = AbstractSyntaxTree(wrapper)
        wrapper.full = True
        parser = Yaml(wrapper, ast)
        parser.parse('.', YAML_WITH_DEFAULT_OFF)
        ast.walk()
        assert len(wrapper.nodes) == 1
开发者ID:GWhized,项目名称:dexy,代码行数:25,代码来源:test_parser.py

示例2: test_generated_files_added_latex_log_ext_array

def test_generated_files_added_latex_log_ext_array():
    with wrap() as wrapper:
        doc = DocNode("example.tex|latex",
            contents = LATEX,
            latex = {'add-new-files' : ['.log']},
            wrapper=wrapper)
        wrapper.run_docs(doc)
开发者ID:GWhized,项目名称:dexy,代码行数:7,代码来源:test_user_docs.py

示例3: test_generated_files_added_latex

def test_generated_files_added_latex():
    with wrap() as wrapper:
        doc = DocNode("example.tex|latex",
            contents = LATEX,
            latex = {'add-new-files' : True},
            wrapper=wrapper)
        wrapper.run_docs(doc)
开发者ID:GWhized,项目名称:dexy,代码行数:7,代码来源:test_user_docs.py

示例4: test_generated_files_added_when_requested_underscore

def test_generated_files_added_when_requested_underscore():
    with wrap() as wrapper:
        doc = DocNode("generate-data.py|py",
            contents = """with open("abc.txt", "w") as f: f.write("hello")""",
            py={"add_new_files" : True},
            wrapper=wrapper)
        wrapper.run_docs(doc)
开发者ID:GWhized,项目名称:dexy,代码行数:7,代码来源:test_user_docs.py

示例5: test_yamlargs_filterargs

def test_yamlargs_filterargs():
    with wrap() as wrapper:
        doc = Doc("example.txt|yamlargs|filterargs",
                wrapper,
                [],
                contents = "%s\n---\r\nThis is the content." % YAML,
                )

        wrapper.run_docs(doc)

        output = doc.output_data().as_text()
        assert "abc: xyz" in output
        assert "foo: 5" in output

        wrapper = Wrapper()
        doc = Doc("example.txt|yamlargs|filterargs",
                wrapper,
                [],
                contents = "%s\n---\r\nThis is the content." % YAML,
                )

        wrapper.run_docs(doc)

        output = doc.output_data().as_text()
        assert "abc: xyz" in output
        assert "foo: 5" in output
开发者ID:GWhized,项目名称:dexy,代码行数:26,代码来源:test_yamlargs_filters.py

示例6: test_yamlargs_with_caching

def test_yamlargs_with_caching():
    with wrap() as wrapper:
        doc = Doc("example.txt|yamlargs",
                wrapper,
                [],
                contents = "title: My Title\n---\r\nThis is the content."
                )
        wrapper.run_docs(doc)

        task = wrapper.nodes["doc:example.txt|yamlargs"]
        assert task.output_data().title() == "My Title"
        assert task.state == 'ran'

        wrapper = Wrapper()
        doc = Doc("example.txt|yamlargs",
                wrapper,
                [],
                contents = "title: My Title\n---\r\nThis is the content."
                )
        wrapper.run_docs(doc)
        task = wrapper.nodes["doc:example.txt|yamlargs"]
        assert task.output_data().title() == "My Title"
        assert task.state == 'consolidated'

        wrapper = Wrapper()
        doc = Doc("example.txt|yamlargs",
                wrapper,
                [],
                contents = "title: My Title\n---\r\nThis is the content."
                )
        wrapper.run_docs(doc)
        task = wrapper.nodes["doc:example.txt|yamlargs"]
        assert task.output_data().title() == "My Title"
        assert task.state == 'consolidated'
开发者ID:GWhized,项目名称:dexy,代码行数:34,代码来源:test_yamlargs_filters.py

示例7: test_generated_files_with_additional_filters

def test_generated_files_with_additional_filters():
    with wrap() as wrapper:
        doc = DocNode("example.tex|latex",
            contents = LATEX,
            latex = {'add-new-files' : ['.aux'], 'additional-doc-filters' : { '.aux' : 'wc' } },
            wrapper=wrapper)
        wrapper.run_docs(doc)
开发者ID:GWhized,项目名称:dexy,代码行数:7,代码来源:test_user_docs.py

示例8: test_subdir_config_with_bundle

def test_subdir_config_with_bundle():
    with wrap():
        with open("dexy.yaml", "w") as f:
            f.write("""
            foo:
                - .txt
            """)

        os.makedirs("abc/def")
        with open("abc/def/dexy.yaml", "w") as f:
            f.write("""
            bar:
                - .py
            """)

        with open("abc/def/hello.py", "w") as f:
            f.write("print 'hello'")

        wrapper = Wrapper()
        wrapper.run_from_new()
        assert "doc:abc/def/hello.py" in wrapper.nodes

        wrapper = Wrapper(recurse=False)
        wrapper.run_from_new()
        assert not "doc:abc/def/hello.py" in wrapper.nodes

        wrapper = Wrapper(recurse=False, configs="abc/def/dexy.yaml")
        wrapper.run_from_new()
        assert "doc:abc/def/hello.py" in wrapper.nodes
开发者ID:GWhized,项目名称:dexy,代码行数:29,代码来源:test_yaml_parser.py

示例9: test_idio_invalid_input

def test_idio_invalid_input():
    with wrap() as wrapper:
        wrapper.debug = False
        doc = Doc("hello.py|idio",
                wrapper, [],
                contents="### @ ")
        wrapper.run_docs(doc)
开发者ID:GWhized,项目名称:dexy,代码行数:7,代码来源:test_id_filters.py

示例10: test_archive_filter

def test_archive_filter():
    with wrap() as wrapper:
        with open("hello.py", "w") as f:
            f.write("print 'hello'")

        with open("hello.rb", "w") as f:
            f.write("puts 'hello'")

        wrapper = Wrapper()
        wrapper.create_dexy_dirs()
        wrapper = Wrapper()

        doc = Doc("archive.tgz|archive",
                wrapper,
                [
                    Doc("hello.py", wrapper),
                    Doc("hello.rb", wrapper),
                    Doc("hello.py|pyg", wrapper),
                    Doc("hello.rb|pyg", wrapper)
                ],
                contents=" ")

        wrapper.run_docs(doc)
        wrapper.report()

        assert os.path.exists("output/archive.tgz")
        tar = tarfile.open("output/archive.tgz", mode="r:gz")
        names = tar.getnames()
        assert "archive/hello.py" in names
        assert "archive/hello.rb" in names
        assert "archive/hello.py-pyg.html" in names
        assert "archive/hello.rb-pyg.html" in names
        tar.close()
开发者ID:GWhized,项目名称:dexy,代码行数:33,代码来源:test_archive_filters.py

示例11: test_pydoc_filter_on_module_names

def test_pydoc_filter_on_module_names():
    with wrap() as wrapper:
        doc = Doc("modules.txt|pydoc", wrapper, [], contents="os math")
        wrapper.run_docs(doc)
        data = doc.output_data()
        assert len(data.keys()) > 100
        assert data["math.e:value"].startswith("2.71828")
开发者ID:GWhized,项目名称:dexy,代码行数:7,代码来源:test_pydoc_filters.py

示例12: test_single_bundle_doc_with_args_2

def test_single_bundle_doc_with_args_2():
    with wrap() as wrapper:
        wrapper.nodes = {}
        wrapper.roots = []
        wrapper.batch = dexy.batch.Batch(wrapper)
        wrapper.filemap = wrapper.map_files()

        ast = AbstractSyntaxTree(wrapper)
        parser = Yaml(wrapper, ast)
        parser.parse('.', """

      -  hello:
            - foo: bar
            - filter_fruit: orange
            - args:
                - ping: pong
            - another-task:
                - foo: baz
                - yet-another-task:
                    - foo: bar
            - one-more-task

      -  more:
            - hello
            - one-more-task
            - foo: bar

        """)

        ast.walk()

        assert wrapper.roots[0].key_with_class() == "bundle:more"
        assert len(wrapper.nodes) == 5
开发者ID:GWhized,项目名称:dexy,代码行数:33,代码来源:test_yaml_parser.py

示例13: test_unprocessed_directory_archive_filter

def test_unprocessed_directory_archive_filter():
    with wrap() as wrapper:
        with open("abc.txt", "w") as f:
            f.write('this is abc')

        with open("def.txt", "w") as f:
            f.write('this is def')

        wrapper = Wrapper()
        wrapper.create_dexy_dirs()
        wrapper = Wrapper()

        doc = Doc("archive.tgz|tgzdir",
                wrapper,
                [],
                contents="ignore",
                tgzdir={'dir' : '.'}
                )
        wrapper.run_docs(doc)
        wrapper.report()

        assert os.path.exists("output/archive.tgz")
        tar = tarfile.open("output/archive.tgz", mode="r:gz")
        names = tar.getnames()

        assert ("./abc.txt" in names) or ("abc.txt" in names)
        assert ("./def.txt" in names) or ("def.txt" in names)
        tar.close()
开发者ID:GWhized,项目名称:dexy,代码行数:28,代码来源:test_archive_filters.py

示例14: test_jinja_pass_through

def test_jinja_pass_through():
    with wrap() as wrapper:
        with open("_template.html", "w") as f:
            f.write("{{ content }}")

        wrapper.reports = 'ws'
        contents = u"{{ link('input.txt') }}"
        doc = Doc("lines.html|jinja",
                    wrapper,
                    [
                        Doc("input.txt",
                            wrapper,
                            [],
                            contents = "nothing to see here"
                            )
                        ],
                    contents=contents,
                    apply_ws_to_content = True
                    )
        wrapper.run_docs(doc)
        assert unicode(doc.output_data()) == contents

        wrapper.report()

        with open("output-site/lines.html", 'r') as f:
            lines_html = f.read()
            assert lines_html == """<a href="/input.txt">Input</a>"""
开发者ID:horaciovasconcellos,项目名称:dexy,代码行数:27,代码来源:test_templating_filters.py

示例15: test_regetron_filter

def test_regetron_filter():
    with wrap() as wrapper:
        wrapper.debug = False
        node = Doc("example.regex|regetron",
                wrapper,
                [
                    Doc("input1.txt",
                        wrapper,
                        [],
                        contents=REGETRON_INPUT_1),
                    Doc("input2.txt",
                        wrapper,
                        [],
                        contents=REGETRON_INPUT_2)
                    ],
                contents="^[a-z\s]+$"
                )

        wrapper.run_docs(node)
        
        if not wrapper.state == 'error':
            assert str(node.output_data()['input1.txt']) == """\
> ^[a-z\s]+$
0000: hello
> 

"""
            assert str(node.output_data()['input2.txt']) == """\
开发者ID:GWhized,项目名称:dexy,代码行数:28,代码来源:test_stdout_input_filters.py


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