def db():
    print('----------setup----------------')
    db = StudentDB()
    db.connect('data.json')
    yield db
    print('----------teardown----------------')
    db.close()
Esempio n. 2
0
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()