summaryrefslogtreecommitdiff
path: root/src
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 /src
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 'src')
-rw-r--r--src/py_session.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/py_session.cc b/src/py_session.cc
index b948997c..167eb2a4 100644
--- a/src/py_session.cc
+++ b/src/py_session.cc
@@ -55,6 +55,9 @@ namespace {
{
return str_to_py_unicode(error_context());
}
+ void py_close_journal_files() {
+ python_session->close_journal_files();
+ }
}
void export_session()
@@ -74,6 +77,8 @@ void export_session()
scope().attr("session") =
object(ptr(static_cast<session_t *>(python_session.get())));
+ scope().attr("close_journal_files") =
+ python::make_function(&py_close_journal_files);
scope().attr("read_journal") =
python::make_function(&py_read_journal,
return_internal_reference<>());