forked from dcolish/flask-markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,45 @@ | ||
from flask import Flask, render_template_string | ||
|
||
from flaskext.markdown import Markdown | ||
mystr = u'This is *markdown*' | ||
|
||
|
||
def run_client(): | ||
app = Flask(__name__) | ||
app.debug = True | ||
md = Markdown(app) | ||
|
||
@app.route('/test_render') | ||
def view_markdown_render(): | ||
|
||
@app.route('/test_inline') | ||
def view_render_inline(): | ||
mystr = u'This is *markdown*' | ||
return render_template_string('{{mystr|markdown}}', mystr=mystr) | ||
|
||
@app.route('/test_var_block') | ||
def view_render_var_block(): | ||
mystr = u'This is a *markdown* block' | ||
template = '''{% filter markdown %}{{mystr}}{% endfilter %}''' | ||
return render_template_string(template, mystr=mystr) | ||
|
||
@app.route('/test_in_block') | ||
def view_render_in_block(): | ||
tmp = u'{% filter markdown %}This is a *markdown* block{% endfilter %}' | ||
return render_template_string(tmp) | ||
|
||
return app.test_client() | ||
|
||
|
||
def test_render_markdown(): | ||
def test_render_inline(): | ||
client = run_client() | ||
resp = client.open('/test_render') | ||
resp = client.open('/test_inline') | ||
assert resp.data == '<p>This is <em>markdown</em></p>' | ||
|
||
|
||
def test_render_var_block(): | ||
client = run_client() | ||
resp = client.open('/test_var_block') | ||
assert resp.data == '<p>This is a <em>markdown</em> block</p>' | ||
|
||
|
||
def test_render_in_block(): | ||
client = run_client() | ||
resp = client.open('/test_in_block') | ||
assert resp.data == '<p>This is a <em>markdown</em> block</p>' |