From 17dac42139a0688f62108b88c216c6b48f5acba5 Mon Sep 17 00:00:00 2001 From: andela-cdike Date: Sun, 27 Aug 2017 20:30:49 +0100 Subject: [PATCH] Tests should use separate shelve test database - Switch from depreccated yield_fixture to fixture decorator --- 19-dyn-attr-prop/oscon/test_schedule1.py | 9 +++++++-- 19-dyn-attr-prop/oscon/test_schedule2.py | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/19-dyn-attr-prop/oscon/test_schedule1.py b/19-dyn-attr-prop/oscon/test_schedule1.py index dbaacc9..ba5dfd1 100644 --- a/19-dyn-attr-prop/oscon/test_schedule1.py +++ b/19-dyn-attr-prop/oscon/test_schedule1.py @@ -1,15 +1,20 @@ +import os import shelve + import pytest import schedule1 as schedule +DB_NAME = 'data/test_db' + -@pytest.yield_fixture +@pytest.fixture(scope='module') def db(): - with shelve.open(schedule.DB_NAME) as the_db: + with shelve.open(DB_NAME) as the_db: if schedule.CONFERENCE not in the_db: schedule.load_db(the_db) yield the_db + os.remove(DB_NAME) def test_record_class(): diff --git a/19-dyn-attr-prop/oscon/test_schedule2.py b/19-dyn-attr-prop/oscon/test_schedule2.py index de09d32..ab1c79c 100644 --- a/19-dyn-attr-prop/oscon/test_schedule2.py +++ b/19-dyn-attr-prop/oscon/test_schedule2.py @@ -1,15 +1,18 @@ +import os import shelve + import pytest import schedule2 as schedule -@pytest.yield_fixture +@pytest.fixture(scope='module') def db(): - with shelve.open(schedule.DB_NAME) as the_db: + with shelve.open(DB_NAME) as the_db: if schedule.CONFERENCE not in the_db: schedule.load_db(the_db) yield the_db + os.remove(DB_NAME) def test_record_attr_access():