本文整理汇总了Python中tests.utils.wrap函数的典型用法代码示例。如果您正苦于以下问题:Python wrap函数的具体用法?Python wrap怎么用?Python wrap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wrap函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_text_parser
def test_text_parser():
with wrap() as wrapper:
with open("f1.py", "w") as f:
f.write("print 'hello'")
with open("f2.py", "w") as f:
f.write("print 'hello'")
with open("index.md", "w") as f:
f.write("")
wrapper = Wrapper()
wrapper.to_valid()
wrapper.nodes = {}
wrapper.roots = []
wrapper.batch = dexy.batch.Batch(wrapper)
wrapper.filemap = wrapper.map_files()
ast = AbstractSyntaxTree(wrapper)
parser = TextFile(wrapper, ast)
parser.parse(".", """
*.py
*.py|pyg
*.md|jinja
""")
ast.walk()
assert len(wrapper.nodes) == 8
开发者ID:GWhized,项目名称:dexy,代码行数:28,代码来源:test_parser.py
示例17: test_generic_data
def test_generic_data():
with wrap() as wrapper:
wrapper.to_walked()
wrapper.to_checked()
CONTENTS = "contents go here"
# Create a GenericData object
settings = {
'canonical-name' : 'doc.txt'
}
data = dexy.data.Generic("doc.txt", ".txt", "abc000", settings, wrapper)
data.setup_storage()
# Assign some text contents
data._data = CONTENTS
assert data.has_data()
assert not data.is_cached(True)
# Save data to disk
data.save()
assert data.has_data()
assert data.is_cached(True)
assert data.filesize(True) > 10
# Clear data from memory
data._data = None
# Load it again from disk
data.load_data(True)
assert data._data == CONTENTS
assert data.as_text() == CONTENTS
开发者ID:GWhized,项目名称:dexy,代码行数:33,代码来源:test_data.py
示例18: test_api_url_without_php_ending_with_trailing_slash
def test_api_url_without_php_ending_with_trailing_slash():
with wrap():
with open(".dexyapis", "wb") as f:
json.dump({ "wordpress" : {"url" : "http://example.com/api/"} }, f)
url = dexy.filter.Filter.create_instance("wp").api_url()
assert url == "http://example.com/api/xmlrpc.php"
开发者ID:GWhized,项目名称:dexy,代码行数:7,代码来源:test_wordpress_filters.py
示例19: test_script_node_caching__slow
def test_script_node_caching__slow():
with wrap():
with open("start.sh", "w") as f:
f.write("pwd")
with open("middle.sh", "w") as f:
f.write("echo `time`")
with open("end.sh", "w") as f:
f.write("echo 'done'")
with open("dexy.yaml", "w") as f:
f.write(SCRIPT_YAML)
wrapper1 = Wrapper(log_level="DEBUG")
wrapper1.run_from_new()
for node in wrapper1.nodes.values():
assert node.state == 'ran'
wrapper2 = Wrapper()
wrapper2.run_from_new()
for node in wrapper2.nodes.values():
assert node.state == 'consolidated'
time.sleep(1.1)
with open("middle.sh", "w") as f:
f.write("echo 'new'")
wrapper3 = Wrapper()
wrapper3.run_from_new()
for node in wrapper1.nodes.values():
assert node.state == 'ran'
开发者ID:GWhized,项目名称:dexy,代码行数:35,代码来源:test_node.py
示例20: test_pattern_node
def test_pattern_node():
with wrap() as wrapper:
with open("foo.txt", "w") as f:
f.write("foo!")
with open("bar.txt", "w") as f:
f.write("bar!")
wrapper = Wrapper(log_level='DEBUG')
wrapper.to_valid()
wrapper.nodes = {}
wrapper.roots = []
wrapper.batch = dexy.batch.Batch(wrapper)
wrapper.filemap = wrapper.map_files()
node = PatternNode("*.txt",
wrapper,
[],
foo="bar")
assert node.args['foo'] == 'bar'
wrapper.run_docs(node)
assert len(node.children) == 2
for child in node.children:
assert child.__class__.__name__ == "Doc"
assert child.args['foo'] == 'bar'
assert child.key_with_class() in ["doc:foo.txt", "doc:bar.txt"]
assert child.filters == []
开发者ID:GWhized,项目名称:dexy,代码行数:29,代码来源:test_node.py
注:本文中的tests.utils.wrap函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论