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
def test_jinja_invalid_attribute(): def make_sections_doc(wrapper): return Doc("sections.txt", wrapper, [], contents=[{}, { "name": "foo", "contents": "This is foo." }]) with wrap() as wrapper: node = Doc( "ok.txt|jinja", wrapper, [make_sections_doc(wrapper)], contents="""hello! foo contents are: {{ d['sections.txt'].foo }}""" ) wrapper.run_docs(node) assert str( node.output_data()) == """hello! foo contents are: This is foo.""" with wrap() as wrapper: node = Doc("broken.txt|jinja", wrapper, [make_sections_doc(wrapper)], contents="""There is no {{ d['sections.txt'].bar }}""") try: wrapper.run_docs(node) except UserFeedback as e: assert str( e) == "No value for bar available in sections or metadata."
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)
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")
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)
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)
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"
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 == []
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
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
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'
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']) == """\
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
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)
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>"""
def test_doc_node_with_filters(): with wrap() as wrapper: node = Node.create_instance('doc', "foo.txt|outputabc", wrapper, [], contents='foo') assert node.key_with_class() == "doc:foo.txt|outputabc"
def test_doc_node_populate(): with wrap() as wrapper: node = Node.create_instance( 'doc', "foo.txt", wrapper, [], contents='foo') assert node.key_with_class() == "doc:foo.txt"
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'
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 list(wrapper1.nodes.values()): assert node.state == 'ran' wrapper2 = Wrapper() wrapper2.run_from_new() for node in list(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 list(wrapper1.nodes.values()): assert node.state == 'ran'
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
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)
def test_generated_files_not_added_by_default(): with wrap() as wrapper: doc = DocNode( "generate-data.py|py", contents="""with open("abc.txt", "w") as f: f.write("hello")""", wrapper=wrapper) wrapper.run_docs(doc)
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)
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")
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"
def test_idio_invalid_input(): with wrap() as wrapper: wrapper.debug = False doc = Doc("hello.py|idio", wrapper, [], contents="### @ ") wrapper.run_docs(doc)
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
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
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
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()
def test_archive_filter_with_short_names(): 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=" ", archive={'use-short-names': True}) 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.html" in names assert "archive/hello.rb.html" in names tar.close()
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()
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()
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'
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
def test_ragel_state_chart_to_image(): ragel = inspect.cleandoc(""" %%{ machine hello_and_welcome; main := ( 'h' @ { puts "hello world!" } | 'w' @ { puts "welcome" } )*; }%% data = 'whwwwwhw' %% write data; %% write init; %% write exec; """) with wrap() as wrapper: graph_png = dexy.doc.Doc("example.rl|rlrbd|dot", wrapper, [], contents=ragel ) syntax = dexy.doc.Doc("example.rl|rlrbd|pyg", wrapper, [], contents=ragel ) wrapper.run_docs(graph_png, syntax) assert graph_png.state == 'ran' assert syntax.state == 'ran'
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>"""
def test_pyparse_filter_on_python_files(): with wrap() as wrapper: doc = Doc("source.py|pyparse", wrapper, [], contents=python_file_content) wrapper.run_docs(doc) data = doc.output_data() keys = list(data.keys()) assert 'bar:source' in keys assert 'foo:source' in keys assert data['foo:doc'] == "docstring for foo" assert data['foo:source'].startswith("def foo():\n") assert data['bar:doc'] == "docstring for bar" assert data['bar:source'].startswith("def bar():\n") assert data['decorated:source'].startswith( "@decorator\n@another\ndef decorated():\n") assert data['Foo:source'].startswith("class Foo(object):\n") assert data['Foo.decorated:source'].startswith( " @decorator\n @another\n def decorated(self):\n")
def test_ragel_state_chart_to_image(): ragel = inspect.cleandoc(""" %%{ machine hello_and_welcome; main := ( 'h' @ { puts "hello world!" } | 'w' @ { puts "welcome" } )*; }%% data = 'whwwwwhw' %% write data; %% write init; %% write exec; """) with wrap() as wrapper: graph_png = dexy.doc.Doc("example.rl|rlrbd|dot", wrapper, [], contents=ragel) syntax = dexy.doc.Doc("example.rl|rlrbd|pyg", wrapper, [], contents=ragel) wrapper.run_docs(graph_png, syntax) assert graph_png.state == 'ran' assert syntax.state == 'ran'
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
def run_jinja_filter(contents): with wrap() as wrapper: doc = Doc("hello.txt|jinja", wrapper, [], contents=contents) wrapper.run_docs(doc) data = doc.output_data() data.data() # make sure is loaded return data
def test_jinja_undefined(): with wrap() as wrapper: wrapper.debug = False node = Doc("template.txt|jinja", wrapper, [], contents="""{{ foo }}""") wrapper.run_docs(node) assert wrapper.state == 'error'
def test_cfussy_filter(): assert_output('cfussy', C_FUSSY_HELLO_WORLD, "HELLO, world\n", ext=".c") with wrap() as wrapper: wrapper.debug = False doc = Doc("hello.c|cfussy", contents=C_HELLO_WORLD, wrapper=wrapper) wrapper.run_docs(doc) assert wrapper.state == 'error'
def test_taverna(): raise SkipTest() with wrap() as wrapper: orig = os.path.join(TEST_DATA_DIR, 'simple_python_example_285475.t2flow') shutil.copyfile(orig, 'simple-python.t2flow') node = Doc("simple-python.t2flow|taverna", wrapper) wrapper.run_docs(node)
def test_word_wrap_filter(): with wrap() as wrapper: node = Doc("example.txt|wrap", wrapper, [], contents="this is a line of text", wrap={"width": 5}) wrapper.run_docs(node) assert str(node.output_data()) == "this\nis a\nline\nof\ntext"
def test_ps2pdf_filter(): with wrap() as wrapper: node = Doc("hello.ps|ps2pdf", wrapper, [], contents = PS) wrapper.run_docs(node) assert node.output_data().is_cached() assert node.output_data().filesize() > 1000
def test_jinja_filter_using_inflection(): with wrap() as wrapper: node = Doc("template.txt|jinja", wrapper, [], contents="""{{ humanize("abc_def") }}""") wrapper.run_docs(node) assert node.output_data().as_text() == "Abc def"
def test_jinja_filter_set_vars(): with wrap() as wrapper: node = Doc("template.txt|jinja", wrapper, [], contents="""{% set foo = 'bar' -%}\nfoo is {{ foo }}\n""") wrapper.run_docs(node) assert node.output_data().as_text() == "foo is bar"
def test_jinja_filter_tex_extension(): with wrap() as wrapper: node = Doc("template.tex|jinja", wrapper, [], contents="1 + 1 is << 1+1 >>") wrapper.run_docs(node) assert node.output_data().as_text() == "1 + 1 is 2"
def test_output_reporter(): with wrap() as wrapper: wrapper.reports = "output" doc = Doc("hello.txt", wrapper, [], contents="hello") wrapper.run_docs(doc) wrapper.report() assert os.path.exists("output") assert os.path.exists("output/hello.txt")
def test_globals(): with wrap() as wrapper: wrapper.globals = "foo=bar" node = Doc("hello.txt|testglobals", wrapper, [], contents="hello") wrapper.run_docs(node) env = node.filters[-1].run_plugins() assert env['foo'][1] == 'bar'
def test_rst2odt(): with wrap() as wrapper: node = Doc("example.txt|rst2odt", wrapper, [], contents=RST) wrapper.run_docs(node) assert node.output_data().filesize() > 8000
def test_jinja_filter_tex_extension(): with wrap() as wrapper: node = Doc("template.tex|jinja", wrapper, [], contents = "1 + 1 is << 1+1 >>") wrapper.run_docs(node) assert node.output_data().as_text() == "1 + 1 is 2"
def test_rust(): with wrap() as wrapper: doc = Doc("example.rs|rustc", wrapper, [], contents = RUST ) wrapper.run_docs(doc) assert str(doc.output_data()) == "hello?\n"
def test_force_text(): with wrap() as wrapper: node = Doc("example.py|idio|t", wrapper, [], contents="print 'hello'\n") wrapper.run_docs(node) assert str(node.output_data()) == "print 'hello'\n"