def cart(): # faking some data (normally would load from DB) products = 'celery apples water coffee chicken pizza'.split() prices = [1, 4, 2, 5, 6, 4] cravings = False, False, False, False, False, True items = [] for item in zip(products, prices, cravings): items.append(Item(*item)) return Groceries(items)
def cart(): """Setup code to create a groceries cart object with 6 items in it""" print('sleeping a bit at session level') sleep(1) # for scope=module/session demo purposes products = 'celery apples water coffee chicken pizza'.split() prices = [1, 4, 2, 5, 6, 4] cravings = False, False, False, False, False, True items = [] for item in zip(products, prices, cravings): items.append(Item(*item)) return Groceries(items)
def empty_grocery_cart(): cart = Groceries() yield cart
def stocked_grocery_cart(items_list): cart = Groceries(items_list) yield cart
def test_initial_empty_cart(): """Note no fixture here to test an empty cart creation""" cart = Groceries() assert len(cart) == 0 assert cart.due == 0