Skip to content
This repository was archived by the owner on Dec 2, 2021. It is now read-only.

Commit 17dac42

Browse files
author
andela-cdike
committed
Tests should use separate shelve test database
- Switch from depreccated yield_fixture to fixture decorator
1 parent 3d74f0e commit 17dac42

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

19-dyn-attr-prop/oscon/test_schedule1.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
import os
12
import shelve
3+
24
import pytest
35

46
import schedule1 as schedule
57

8+
DB_NAME = 'data/test_db'
9+
610

7-
@pytest.yield_fixture
11+
@pytest.fixture(scope='module')
812
def db():
9-
with shelve.open(schedule.DB_NAME) as the_db:
13+
with shelve.open(DB_NAME) as the_db:
1014
if schedule.CONFERENCE not in the_db:
1115
schedule.load_db(the_db)
1216
yield the_db
17+
os.remove(DB_NAME)
1318

1419

1520
def test_record_class():

19-dyn-attr-prop/oscon/test_schedule2.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
import os
12
import shelve
3+
24
import pytest
35

46
import schedule2 as schedule
57

68

7-
@pytest.yield_fixture
9+
@pytest.fixture(scope='module')
810
def db():
9-
with shelve.open(schedule.DB_NAME) as the_db:
11+
with shelve.open(DB_NAME) as the_db:
1012
if schedule.CONFERENCE not in the_db:
1113
schedule.load_db(the_db)
1214
yield the_db
15+
os.remove(DB_NAME)
1316

1417

1518
def test_record_attr_access():

0 commit comments

Comments
 (0)