Question: This problem will test your ability to create an automated test using the unittest module. For this problem, make sure you download the display _

This problem will test your ability to create an automated test using the unittest module.
For this problem, make sure you download the display_utils.py function module and place it in the same directory where you create a file called Lab13P5.py.
Review the display_util.py code. Note that it has two functions:
get_user_greeting takes one parameter and returns a string that includes the name in a greeting.
sum_is_greater takes three parameters. It returns True if the sum of the first two parameters is greater than the third parameter.
The Lab12P5.py file will implement two automated tests that will test each of these functions. Do the following:
Import both the unittest and the display_utils modules.
Create a class called TestDisplayUtils. Inside the parenthesis, specify unittest.TestCase. That will indicate that the class you created is a subclass of the TestCase class inside of the unittest module.
Create two methods:
o test_get_user_greeting has only one parameter, the self parameter.
This test method should call get_user_greeting inside of display_utils and pass it the name Bob. The return value should be assigned to the variable greeting:
greeting = display_utils.get_user_greeting(Bob)
The test method should then use the assertEqual method available via the self parameter to see if greeting is equal to:
Hello Bob!
o test_sum_is_greater has only one parameter, the self parameter.
This test method should call the assertTrue method that is available via the self parameter. It should pass the following into that method:
display_utils.sum_is_greater(5,8,12)
This function call is nested inside the call to assertTrue.
At the end of Lab12P5.py, you need to add two lines that will enable this test to call the unittest main this Python file is directly called from Python:
if __name__=='__main__':
unittest.main()
Note, that there are two underscores before and after name and main on the line with the if statement.
After completing the implementation, run the file from the command line in the Terminal. You should see something similar to this sample output:
Sample output:
PS C:\PycharmProjects\WakeTech\Lab12> python Lab13P5.py
F.
======================================================================
FAIL: test_get_user_greeting (__main__.TestDisplayUtils.test_get_user_greeting)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\PycharmProjects\WakeTech\Lab12\Lab13P5.py", line 12, in test_get_user_greeting
self.assertEqual(greeting, 'Hello Bob!')
AssertionError: 'Hello-Bob!'!= 'Hello Bob!'
- Hello-Bob!
?^
+ Hello Bob!
?^
----------------------------------------------------------------------
Ran 2 tests in 0.001s
FAILED (failures=1)
This exercise has been designed so the first of the two tests will FAIL. The test itself is valid but the code in display_utils.py has a bug. Make sure that you turn in the Python unittest file you created from these instructions that found this bug and do NOT change the tests so that the bug is not detected.

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!