def add_product(basket, price=None, quantity=1, product=None):
    """
    Helper to add a product to the basket.
    """
    has_strategy = False
    try:
        has_strategy = hasattr(basket, 'strategy')
    except __HOLE__:
        pass
    if not has_strategy:
        basket.strategy = strategy.Default()
    if price is None:
        price = D('1')
    if product and product.has_stockrecords:
        record = product.stockrecords.all()[0]
    else:
        record = factories.create_stockrecord(
            product=product, price_excl_tax=price,
            num_in_stock=quantity + 1)
    basket.add_product(record.product, quantity)
dataset/ETHPy150Open django-oscar/django-oscar/src/oscar/test/basket.py/add_product