Skip to content

Instantly share code, notes, and snippets.

@afh
Created December 16, 2014 20:21
Show Gist options
  • Save afh/4596839560eead5e1d1f to your computer and use it in GitHub Desktop.
Save afh/4596839560eead5e1d1f to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import unittest
from ledger import *
class JournalTestCase(unittest.TestCase):
def _tearDown(self):
pass # session.close_journal_files()
def testCloseJournalFiles(self):
print "reading journal"
journal = read_journal_from_string("""
2012-03-01 KFC
Expenses:Food $21.34
Assets:Cash
""")
print "done reading journal"
print "closing journal files"
session.close_journal_files()
print "done closing journal files"
def _testBasicRead(self):
journal = read_journal_from_string("""
2012-03-01 KFC
Expenses:Food $21.34
Assets:Cash
""")
self.assertEqual(type(journal), Journal)
for xact in journal:
self.assertEqual(xact.payee, "KFC")
for post in journal.query("food"):
self.assertEqual(str(post.account), "Expenses:Food")
self.assertEqual(post.amount, Amount("$21.34"))
def suite():
return unittest.TestLoader().loadTestsFromTestCase(JournalTestCase)
if __name__ == '__main__':
unittest.main()
afh@kei(master)✗ [139]% PYTHONPATH=. python -B test/python/JournalTest.py ~/src/ledger 🕣
python_session.reset
~journal_t()
reading journal
done reading journal
closing journal files
~journal_t()
[1] 14620 segmentation fault PYTHONPATH=. python -B test/python/JournalTest.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment