Test pidgy.weave
¶
import pidgy, IPython
import pidgy, IPython
weave = pidgy.weave.Weave(parent=IPython.get_ipython())
weave = pidgy.weave.Weave(parent=IPython.get_ipython())
s = """A string to template with a variable: {{foo|default('default')}}."""
s = """A string to template with a variable: default."""
>>> weave.render(s)
'A string to template with a variable: default.'
>>> weave.render(s)
'A string to template with a variable: default.'
foo = 10
>>> weave.render(s)
'A string to template with a variable: 10.'
foo = 10
>>> weave.render(s)
'A string to template with a variable: 10.'
'A string to template with a variable: 900.'
'A string to template with a variable: 900.'
'A string to template with a variable: 900.'
>>> assert False
>>> assert 0
>>> assert False
>>> assert 0
Traceback (most recent call last):
File "/home/tonyfast/miniconda3/lib/python3.7/doctest.py", line 2197, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for In[7]
File "In[7]", line 1, in In[7]
----------------------------------------------------------------------
File "In[7]", line 2, in In[7]
Failed example:
assert False
Exception raised:
Traceback (most recent call last):
File "/home/tonyfast/miniconda3/lib/python3.7/doctest.py", line 1330, in __run
compileflags, 1), test.globs)
File "In[9]", line 1, in <module>
AssertionError
----------------------------------------------------------------------
File "In[7]", line 3, in In[7]
Failed example:
assert 0
Exception raised:
Traceback (most recent call last):
File "/home/tonyfast/miniconda3/lib/python3.7/doctest.py", line 1330, in __run
compileflags, 1), test.globs)
File "In[9]", line 1, in <module>
AssertionError
Load variables that are defined in the templated_document.md.
import sys; foo = "default"
sys.argv = ['empty']
{% include "templated_document.md" %}
Load variables that are defined in the templated_document.md.
import sys; foo = "default"
sys.argv = ['empty']
#!/usr/bin/env python3 -m pidgy template
foo
is defined as default
My document recieved ['empty'] as arguments.
https://en.wikipedia.org/wiki/Bauhaus