Skip to content
This repository has been archived by the owner on Nov 25, 2017. It is now read-only.

Commit

Permalink
Added a few tests for named parsers, invalid names, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobian committed Oct 7, 2011
1 parent b50c8df commit 83ac8f7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/__init__.py
Expand Up @@ -64,3 +64,29 @@ def test_xml_css(self):
headers = False
)
self.assertEqual(t[0][1], "Jefferson County International")

# This short URL for the next couple tests points to the Lawrence PD crime
# remote from the test_html_* methods above.

def test_failed_parser_guessing(self):
with self.assertRaises(ValueError) as cm:
remotetable.open('http://bit.ly/qhMkBl')
self.assertEqual(str(cm.exception), "Can't guess a parser for URL 'http://bit.ly/qhMkBl'")

def test_named_parser(self):
t = remotetable.open('http://bit.ly/qhMkBl',
parser = 'html',
row_css = 'table table tr',
column_css = 'td, th',
select = lambda row: bool(row['UCR Classification'])
)
self.assertEqual(t[0]['UCR Classification'], '100 - Kidnapping / Abduction')

def test_invalid_named_parser(self):
with self.assertRaises(ValueError) as cm:
remotetable.open('http://bit.ly/qhMkBl', parser='flahflarg')
self.assertEqual(
str(cm.exception),
"Can't find or load a parser named 'flahflarg': No module named flahflarg"
)

0 comments on commit 83ac8f7

Please sign in to comment.