summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Sklar <177495+davidsklar@users.noreply.github.com>2022-12-29 13:37:27 -0500
committerMartin Michlmayr <tbm@cyrius.com>2023-01-09 22:43:37 +0800
commitc43098d5bd91b6af733cb19225ebaf29228c2c50 (patch)
treedb4bfc04fc2526009db4c0b58c1b65b50d19069d /test
parent1eec9f86667cad3b0bbafb82a83739a0d30ca09f (diff)
downloadfork-ledger-c43098d5bd91b6af733cb19225ebaf29228c2c50.tar.gz
fork-ledger-c43098d5bd91b6af733cb19225ebaf29228c2c50.tar.bz2
fork-ledger-c43098d5bd91b6af733cb19225ebaf29228c2c50.zip
Python: test cleanups
1. Remove references to modules (exceptions, StringIO) no longer needed for Pythn3 2. Use assertEqual instead of assertEquals 3. Clear journal files with a close_journal_files() function that uses the then-current underlying python_session pointer. Calling session.close_journal_files() sometimes leads to segfaults because python_session has changed after it was injected into the python module (as "session") on module startup.
Diffstat (limited to 'test')
-rw-r--r--test/python/JournalTest.py4
-rw-r--r--test/python/PostingTest.py4
-rw-r--r--test/python/TransactionTest.py4
3 files changed, 4 insertions, 8 deletions
diff --git a/test/python/JournalTest.py b/test/python/JournalTest.py
index 2565ede8..84ad2f43 100644
--- a/test/python/JournalTest.py
+++ b/test/python/JournalTest.py
@@ -6,7 +6,7 @@ from ledger import *
class JournalTestCase(unittest.TestCase):
def tearDown(self):
- session.close_journal_files()
+ close_journal_files()
def testBasicRead(self):
journal = read_journal_from_string("""
@@ -37,7 +37,7 @@ class JournalTestCase(unittest.TestCase):
try:
fun()
except RuntimeError as e:
- self.assertEquals(str(e).splitlines()[-1],
+ self.assertEqual(str(e).splitlines()[-1],
"No quantity specified for amount")
diff --git a/test/python/PostingTest.py b/test/python/PostingTest.py
index f191253e..0dd18112 100644
--- a/test/python/PostingTest.py
+++ b/test/python/PostingTest.py
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
import unittest
-import exceptions
import operator
from ledger import *
-from StringIO import *
from datetime import *
class PostingTestCase(unittest.TestCase):
@@ -13,7 +11,7 @@ class PostingTestCase(unittest.TestCase):
pass
def tearDown(self):
- pass
+ close_journal_files()
def test_(self):
pass
diff --git a/test/python/TransactionTest.py b/test/python/TransactionTest.py
index 66447f87..257eb377 100644
--- a/test/python/TransactionTest.py
+++ b/test/python/TransactionTest.py
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
import unittest
-import exceptions
import operator
from ledger import *
-from StringIO import *
from datetime import *
class JournalTestCase(unittest.TestCase):
@@ -13,7 +11,7 @@ class JournalTestCase(unittest.TestCase):
pass
def tearDown(self):
- pass
+ close_journal_files()
def test_(self):
pass