-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from msabramo/rst_tests
Add tests for RST rendering
- Loading branch information
Showing
13 changed files
with
139 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div id="required-packages"> | ||
<h2>Required packages</h2> | ||
<p>To run the PyPI software, you need Python 2.5+ and PostgreSQL</p> | ||
</div> | ||
<div id="quick-development-setup"> | ||
<h2>Quick development setup</h2> | ||
<p>Make sure you are sitting</p> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Required packages | ||
----------------- | ||
|
||
To run the PyPI software, you need Python 2.5+ and PostgreSQL | ||
|
||
|
||
Quick development setup | ||
----------------------- | ||
|
||
Make sure you are sitting |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<p><div id=”required-packages”> | ||
<h2>Required packages</h2> | ||
<p>To run the PyPI software, you need Python 2.5+ and PostgreSQL</p> | ||
</div> | ||
<div id=”quick-development-setup”> | ||
<h2>Quick development setup</h2> | ||
<p>Make sure you are sitting</p> | ||
</div></p> |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div id="required-packages"> | ||
<h2>Required packages</h2> | ||
<p>To run the PyPI software, you need Python 2.5+ and PostgreSQL</p> | ||
</div> | ||
<div id="quick-development-setup"> | ||
<h2>Quick development setup</h2> | ||
<p>Make sure you are sitting</p> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<p><a href=”<a rel="nofollow" href="http://mymalicioussite.com/">http://mymalicioussite.com/</a>”>Click here</a></p> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<a href="http://mymalicioussite.com/">Click here</a> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<p><iframe src=”<a rel="nofollow" href="http://mymalicioussite.com/">http://mymalicioussite.com/</a>”>Click here</iframe></p> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<iframe src="http://mymalicioussite.com/">Click here</iframe> |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Something naughty this way comes | ||
<script> | ||
alert("Hello"); | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Something naughty this way comes | ||
<script> | ||
alert("Hello"); | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<p>Here is some Python code for a <tt>Dog</tt>:</p> | ||
<pre><span class="k">class</span> <span class="nc">Dog</span><span class="p">(</span><span class="n">Animal</span><span class="p">):</span> | ||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span> | ||
|
||
<span class="k">def</span> <span class="nf">make_sound</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="k">print</span><span class="p">(</span><span class="s">'Ruff!'</span><span class="p">)</span> | ||
|
||
<span class="n">dog</span> <span class="o">=</span> <span class="n">Dog</span><span class="p">(</span><span class="s">'Fido'</span><span class="p">)</span> | ||
</pre> | ||
<p>and then here is some bash:</p> | ||
<pre><span class="k">if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$1</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"--help"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span> | ||
<span class="nb">echo</span> <span class="s2">"OK"</span> | ||
<span class="k">fi</span> | ||
</pre> | ||
<p>or click <a rel="nofollow" href="http://www.surveymonkey.com">SurveyMonkey</a></p> |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Here is some Python code for a ``Dog``: | ||
|
||
.. code-block:: python | ||
class Dog(Animal): | ||
def __init__(self, name): | ||
self.name = name | ||
def make_sound(self): | ||
print('Ruff!') | ||
dog = Dog('Fido') | ||
and then here is some bash: | ||
|
||
.. code-block:: bash | ||
if [ "$1" = "--help" ]; then | ||
echo "OK" | ||
fi | ||
or click `SurveyMonkey <http://www.surveymonkey.com>`_ |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import codecs | ||
import os | ||
|
||
from readme.rst import render | ||
|
||
|
||
def test_rst_001(): | ||
assert render('Hello') == ('<p>Hello</p>\n', True) | ||
|
||
|
||
def test_rst_002(): | ||
assert render('http://mymalicioussite.com/') == ( | ||
('<p><a rel="nofollow" href="http://mymalicioussite.com/">' + | ||
'http://mymalicioussite.com/</a></p>\n'), | ||
True) | ||
|
||
|
||
def test_rst_003(): | ||
_do_test_with_files('test_rst_003') | ||
|
||
|
||
def test_rst_004(): | ||
_do_test_with_files('test_rst_004') | ||
|
||
|
||
def test_rst_005(): | ||
_do_test_with_files('test_rst_005') | ||
|
||
|
||
def test_rst_006(): | ||
_do_test_with_files('test_rst_006') | ||
|
||
|
||
def test_rst_007(): | ||
_do_test_with_files('test_rst_007', expected_rendered=False) | ||
|
||
|
||
def test_rst_008(): | ||
_do_test_with_files('test_rst_008') | ||
|
||
|
||
def _do_test_with_files(test_name, expected_rendered=True): | ||
rst_markup = read('{0}.rst'.format(test_name)) | ||
expected_html = read('{0}.html'.format(test_name)) | ||
|
||
out, rendered = render(rst_markup) | ||
|
||
assert rendered == expected_rendered | ||
assert out == expected_html | ||
|
||
|
||
def read(fn): | ||
path = os.path.join(os.path.dirname(__file__), 'fixtures', fn) | ||
with codecs.open(path, encoding='utf-8') as f: | ||
return f.read() |