Question: a Python script where you import unittest and a subclass of unittest.TestCase to test the Employee class from the module skills.py (see link in assignment;
a Python script where you import unittest and a subclass of unittest.TestCase to test the Employee class from the module skills.py (see link in assignment; please look at the docstrings to get a sense of what each method does).
Your script should satisfy the following criteria:
It should import the unittest module.
It should import the Employee class from the skills module (i.e., skills.py; make sure skills.py is in the same directory as your script).
It contain one class, a subclass of unittest.TestCase. Your class declaration will look something like this:
class TestSkills(unittest.TestCase):
The part in parentheses is the part that makes your class a subclass of the unittest.TestCase class. This is called
inheritance; we'll discuss this on Thursday.
Your class should have a setUp() method in which you create two instances of Employee.
Settheseasattributesofyourclass(e.g.,self.loriandself.gary).
Give them sets of skills that overlap partially.For example,oneknowsPython,
and they both know Qualtrics and Tableau.
Your class should have a test_name() method that uses self.assertEqual() to ensure that your Employee
instances' name attributes are correct.
Your class should have a test_validation() method that uses self.assertRaises() in a with statement. In the body if the with statement, your code should try to an instance of Employee with an invalid name or skill set (for example, you might use an integer for a name, or provide a list of skills instead of a set). In either case, the __init__() method of Employee should raise a ValueError.
Your class should have a test_complementary_skills() method that uses self.assertIn() and self.assertNotIn() to check the return value of self.complementary_skills(). (For example, if self.lori has R in her skills and self.gary has Python in his, and both have Qualtrics and Tableau, then self.lori.complementary_skills(self.gary) should return a set that contains R and Python but not Qualtrics or Tableau.
Your script should end with the following code: if __name__ == '__main__':
unittest.main()
This code the unittest module to run all subclasses of unittest.TestCase.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
