diff options
author | John Wiegley <johnw@newartisans.com> | 2016-04-20 21:28:14 -0700 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2016-04-20 21:28:14 -0700 |
commit | 8bdc0bba7cbd2b1c404553793468ced78170849a (patch) | |
tree | 63b13116f1f0a71dfe474cc8ddf636658da6a199 /test/python | |
parent | 6065ad71fc693c2d03ed0db9742ea4b41a7a2ac5 (diff) | |
parent | d300dfefec6210a326bdd12f12be1a93db305dab (diff) | |
download | fork-ledger-8bdc0bba7cbd2b1c404553793468ced78170849a.tar.gz fork-ledger-8bdc0bba7cbd2b1c404553793468ced78170849a.tar.bz2 fork-ledger-8bdc0bba7cbd2b1c404553793468ced78170849a.zip |
Merge pull request #446 from Rudd-O/truepyerrors
Ensure that parse errors produce useful RuntimeErrors for Python code.
Diffstat (limited to 'test/python')
-rw-r--r-- | test/python/JournalTest.py | 18 |
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) |