Question: Define a pytest test class 'TestingInventoryCreation' which tests the behavior of the '__init__' method with the following tests: Define a pytest test method 'test_creating_empty_inventory' ,

Define a pytest test class'TestingInventoryCreation'which tests the behavior of the'__init__'method with the following tests:

  • Define a pytest test method'test_creating_empty_inventory', which creates an empty inventory and checks if its 'balance_inventory' is an empty dict.
  • Define a pytest test method'test_creating_specified_inventory', which creates an inventory instance with input {'iPhone Model X':100, 'Xiaomi Model Y': 1000, 'Nokia Model Z':25}.
  • Define a pytest test method'test_creating_inventory_with_list', which checks if the'__init__'method raises a TypeError with the message "Input inventory must be a dictionary" when a list "['iPhone Model X', 'Xiaomi Model Y', 'Nokia Model Z']" is passed as input.
  • Define a pytest test method'test_creating_inventory_with_numeric_keys', which checks if the'__init__'method raises a ValueError with the message "Mobile model name must be a string", when the dict {1:'iPhone Model X', 2:'Xiaomi Model Y', 3:'Nokia Model Z'} is passed as input.
  • Define a pytest test method'test_creating_inventory_with_nonnumeric_values', which checks if the'__init__'method raises a ValueError with the message "No. of mobiles must be a positive integer" when the dict {'iPhone Model X':'100', 'Xiaomi Model Y': '1000', 'Nokia Model Z':'25'} is passed as input.
  • Define a pytest test method'test_creating_inventory_with_negative_value', which checks if the'__init__'method raises a ValueError with the message "No. of mobiles must be a positive integer" when the dict {'iPhone Model X':-45, 'Xiaomi Model Y': 200, 'Nokia Model Z':25} is passed as input.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!