コード例 #1
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'
コード例 #2
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'
コード例 #3
0
def db():
    print('----------setup----------------')
    db = StudentDB()
    db.connect('data.json')
    yield db
    print('----------teardown----------------')
    db.close()
コード例 #4
0
ファイル: test_math_func.py プロジェクト: njsdias/Pytest
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()
コード例 #5
0
def setup_module(module):
    print(" -> This is a setup method")
    global db
    db = StudentDB()
    db.connect("data.json")
コード例 #6
0
def db():
    print("=======SETUP=======")
    db = StudentDB()
    db.connect("data.json")
    return db