summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorManuel Amador (Rudd-O) <rudd-o@rudd-o.com>2016-02-08 04:58:01 +0000
committerManuel Amador (Rudd-O) <rudd-o@rudd-o.com>2016-02-08 04:58:01 +0000
commitd300dfefec6210a326bdd12f12be1a93db305dab (patch)
tree93476be789cbe7894ae93e1aba7bc193826f8043 /test
parent80058dfe8fb384f6e1529afa810c6a9bd08cdf88 (diff)
downloadfork-ledger-d300dfefec6210a326bdd12f12be1a93db305dab.tar.gz
fork-ledger-d300dfefec6210a326bdd12f12be1a93db305dab.tar.bz2
fork-ledger-d300dfefec6210a326bdd12f12be1a93db305dab.zip
Add parse error test
Diffstat (limited to 'test')
-rw-r--r--test/python/JournalTest.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/python/JournalTest.py b/test/python/JournalTest.py
index e65c671d..2565ede8 100644
--- a/test/python/JournalTest.py
+++ b/test/python/JournalTest.py
@@ -22,6 +22,24 @@ class JournalTestCase(unittest.TestCase):
for post in journal.query("food"):
self.assertEqual(str(post.account), "Expenses:Food")
self.assertEqual(post.amount, Amount("$21.34"))
+
+ def testParseError(self):
+ # TODO: ledger spits out parse errors to standard out.
+ # This should not happen, especially when the error
+ # has already been captured by a Python exception.
+ def fun():
+ read_journal_from_string("""
+2012-03-01 KFC
+ Expenses:Food rsnetnirsnti
+ Assets:Cash
+""")
+ self.assertRaises(RuntimeError, fun)
+ try:
+ fun()
+ except RuntimeError as e:
+ self.assertEquals(str(e).splitlines()[-1],
+ "No quantity specified for amount")
+
def suite():
return unittest.TestLoader().loadTestsFromTestCase(JournalTestCase)