def cur(): print("Setting Up") db = MyDB() conn = db.connect("server") curs = conn.cursor() yield curs curs.close() conn.close() print("Closing DB")
def cur(): db = MyDB() conn = db.connect("server") curs = conn.cursor() # return curs # asi se crea uno por test yield curs # asi se crea una sola vez curs.close() # va con el yield conn.close() # va con el yield print("teardown")
def cur(): print("setting up") db = MyDB() conn = db.connect("server") curs = conn.cursor() yield curs curs.close() conn.close() print("closing connection")
def cur(): print("setting up") db = MyDB() conn = db.connect("server") cur = conn.cursor() # yield cursor so can run the close op later yield cur cur.close() conn.close() print("close DB")
def cur(): print("\n-----------------setting DB-------------------") db = MyDB() conn = db.connect("server") curs = conn.cursor() yield curs # yields iterative # Return sends a specified value back to its caller # whereas Yield can produce a sequence of values. curs.close() conn.close() print("\n---------------------closing DB--------------------")
def setup_module(module): global conn, cur db = MyDB() conn = db.connect("server") cur = conn.cursor()