Skip to content

Commit 288493d

Browse files
committed
add test for issue #28.
1 parent e4fa841 commit 288493d

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/test_github_issues.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,35 @@ def test_github_issue_27():
5050
result = textile.textile(test)
5151
expect = """\t<ul>\n\t\t<li>Folders with &#8220;:&#8221; in their names are displayed with a forward slash &#8220;/&#8221; instead. (Filed as <a href="/test/link">#4581709</a>, which was considered &#8220;normal behaviour&#8221; &#8211; quote: &#8220;Please note that Finder presents the &#8216;Carbon filesystem&#8217; view, regardless of the underlying filesystem.&#8221;)</li>\n\t</ul>"""
5252
assert result == expect
53+
54+
def test_github_issue_28():
55+
test="""So here I am porting my ancient "newspipe":newspipe "front-end":blog/2006/09/30/0950 to "Snakelets":Snakelets and "Python":Python, and I've just trimmed down over 20 lines of "PHP":PHP down to essentially one line of "BeautifulSoup":BeautifulSoup retrieval:
56+
57+
<pre>
58+
def parseWapProfile(self, url):
59+
result = fetch.fetchURL(url)
60+
soup = BeautifulStoneSoup(result['data'], convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
61+
try:
62+
width, height = soup('prf:screensize')[0].contents[0].split('x')
63+
except:
64+
width = height = None
65+
return {"width": width, "height": height}
66+
</pre>
67+
68+
Of course there's a lot more error handling to do (and useful data to glean off the "XML":XML), but being able to cut through all the usual parsing crap is immensely gratifying."""
69+
result = textile.textile(test)
70+
expect = ("""\t<p>So here I am porting my ancient <a href="newspipe">newspipe</a> <a href="blog/2006/09/30/0950">front-end</a> to <a href="Snakelets">Snakelets</a> and <a href="Python">Python</a>, and I&#8217;ve just trimmed down over 20 lines of <a href="PHP"><span class="caps">PHP</span></a> down to essentially one line of <a href="BeautifulSoup">BeautifulSoup</a> retrieval:</p>
71+
72+
<pre>
73+
def parseWapProfile(self, url):
74+
result = fetch.fetchURL(url)
75+
soup = BeautifulStoneSoup(result[&#39;data&#39;], convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
76+
try:
77+
width, height = soup(&#39;prf:screensize&#39;)[0].contents[0].split(&#39;x&#39;)
78+
except:
79+
width = height = None
80+
return {&#34;width&#34;: width, &#34;height&#34;: height}
81+
</pre>
82+
83+
\t<p>Of course there&#8217;s a lot more error handling to do (and useful data to glean off the <a href="XML"><span class="caps">XML</span></a>), but being able to cut through all the usual parsing crap is immensely gratifying.</p>""")
84+
assert result == expect

0 commit comments

Comments
 (0)