From f08ae49834ebe63bcf3c9f6311ed8c672b2e9478 Mon Sep 17 00:00:00 2001 From: collerek Date: Mon, 7 Dec 2020 13:08:07 +0100 Subject: [PATCH] fix connecting --- tests/test_saving_related.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test_saving_related.py b/tests/test_saving_related.py index 0676a26..537ddb4 100644 --- a/tests/test_saving_related.py +++ b/tests/test_saving_related.py @@ -46,9 +46,11 @@ def create_test_database(): @pytest.mark.asyncio async def test_model_relationship(): - cat = await Category(name="Foo", code=123).save() - ws = await Workshop(topic="Topic 1", category=cat).save() + async with db: + async with db.transaction(force_rollback=True): + cat = await Category(name="Foo", code=123).save() + ws = await Workshop(topic="Topic 1", category=cat).save() - assert ws.id == 1 - assert ws.topic == "Topic 1" - assert ws.category.name == "Foo" + assert ws.id == 1 + assert ws.topic == "Topic 1" + assert ws.category.name == "Foo"