1
0
forked from GitHub/gf-core

Fix handlers for 'with' syntax in Transaction object

This commit is contained in:
John J. Camilleri
2021-09-21 23:54:55 +02:00
parent 4af807c982
commit 60c9ab4c53
3 changed files with 13 additions and 8 deletions

View File

@@ -330,6 +330,8 @@ static PyGetSetDef PGF_getseters[] = {
};
static PyMemberDef PGF_members[] = {
// {"revision", T_PYSSIZET, offsetof(PGFObject, revision), READONLY,
// "the revision number of this PGF"},
{NULL} /* Sentinel */
};

View File

@@ -18,7 +18,9 @@ def gr2(gr1):
return gr1
@pytest.fixture(scope="module")
def gr3(gr1):
def gr3():
# TODO how to avoid reloading from file?
gr1 = readPGF("../haskell/tests/basic.pgf")
with gr1.newTransaction("bar_branch") as t:
t.createFunction("bar", ty, 0, prob),
t.createCategory("R", [(BIND_TYPE_EXPLICIT, "x", ty)], prob)
@@ -62,8 +64,8 @@ def test_extended_function_prob(gr2):
# gr3
# def test_branched_functions(gr3):
# assert gr3.functions == ["bar", "c", "ind", "s", "z"]
#
# def test_branched_function_type(gr3):
# assert gr3.functionType("bar") == ty
def test_branched_functions(gr3):
assert gr3.functions == ["bar", "c", "ind", "s", "z"]
def test_branched_function_type(gr3):
assert gr3.functionType("bar") == ty

View File

@@ -47,6 +47,7 @@ Transaction_commit(TransactionObject *self, PyObject *args)
return NULL;
}
pgf_free_revision(self->pgf->db, self->pgf->revision);
self->pgf->revision = self->revision;
Py_RETURN_TRUE;
@@ -156,10 +157,10 @@ Transaction_dropCategory(TransactionObject *self, PyObject *args)
Py_RETURN_NONE;
}
static PyObject *
static TransactionObject *
Transaction_enter(TransactionObject *self, PyObject *Py_UNUSED(ignored))
{
Py_RETURN_TRUE;
return self;
}
static PyObject *