Python Quals Pytest
Python Quals Pytest
import os
sys.path.append(os.getcwd())
from proj.inventory import MobileInventory, InsufficientException
import pytest
# Import MobileInventory class and InsufficientException from the inventory module
using the expression from proj.inventory import MobileInventory,
InsufficientException.
# Import pytest using the expression import pytest.
# Use assert statement for assert, and to check. Ex: assert 1 == 1
inventory = None
@classmethod
# Define a pytest class fixture 'setup_class', which creates an
**'MobileInventory'** instance with input {'iPhone Model X':100, 'Xiaomi Model Y':
1000, 'Nokia Model Z':25} and assign it to class attribute **'inventory'**.
def setup_class(cls):
cls.inventory = MobileInventory({'iPhone Model X':100, 'Xiaomi Model
Y':1000, 'Nokia Model Z':25})
with pytest.raises(InsufficientException):
assert "No Stock. New Model Request" ==
MobileInventory.sell_stock(self.inventory,{'iPhone Model B':2, 'Xiaomi Model B':5})