def db(): print('----------setup----------------') db = StudentDB() db.connect('data.json') yield db print('----------teardown----------------') db.close()
def db(): print('-------------setup-------------') db = StudentDB() # just initialize StudentDB() db.connect('data.json') # call connect method to access the json datafile # return db # used without teardown yield db print('-------------teardown-------------') db.close()