def db():
    print('----------setup----------------')
    db = StudentDB()
    db.connect('data.json')
    yield db
    print('----------teardown----------------')
    db.close()
Example #2
0
def test_mark_data(db):
    db = StudentDB()  # init class
    db.connect('data.json')
    scott_data = db.get_data('Mark')
    assert scott_data['id'] == 2
    assert scott_data['name'] == 'Mark'
    assert scott_data['result'] == 'fail'
Example #3
0
def test_scott_data(db):
    db = StudentDB()  # init class
    db.connect('data.json')
    scott_data = db.get_data('Scott')
    assert scott_data['id'] == 1
    assert scott_data['name'] == 'Scott'
    assert scott_data['result'] == 'pass'
Example #4
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()
Example #5
0
def setup_module(module):
    print(" -> This is a setup method")
    global db
    db = StudentDB()
    db.connect("data.json")
def db():
    print("=======SETUP=======")
    db = StudentDB()
    db.connect("data.json")
    return db