Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assignment Instructions For this assignment you will be writing unit tests based on instructions below. In all cases, you should create a separate module (
Assignment Instructions
For this assignment you will be writing unit tests based on instructions below. In all cases, you should create a separate module script file which contains your unit test class.class that inherits from Python's TestCase class in the unittest module and create a set of unit
tests using blackbox testing principles that ensures that identifies and appropriately tests all of
the different equivalence classes and permutations of those classes for the function described
above.
PasswordCheck.py
Below is python code for a function that will check supplied password to determine whether or
not it is a valid password. Valid passwords must be at least characters long and contain at
least one of each of the following types of characters: uppercase letter, lowercase letter,
contain any 'illegal' characters, which is any character which is not an uppercaselowercase
letter, number, or special character. If a password is valid, the function returns the value True,
otherwise it raises an exception with a message explaining why the password is incorrect.
def passwordcheckpassword:
if not isinstance password str:
raise TypeErrorpassword must be a string"
if lenpassword :
raise ValueErrorpassword must be at least characters long"
lowercount, uppercount, numbercount, specialcount
for char in password:
if char in "abcdefghijklmnopqrstuvwxyz":
lowercount
elif char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
uppercount
elif char in :
numbercount
elif char in #&&
specialcount
else:
raise ValueErrorpassword cannot contain illegal character: char
if lowercount :
raise ValueErrorpassword must contain at least lowercase character"
if uppercount :
raise ValueErrorpassword must contain at least uppercase character"
if numbercount :
raise ValueErrorpassword must contain at least number character"
if specialcount :
raise ValueErrorpassword must contain at least special character"
return True
Create a module with a PasswordCheckTest class that inherits from Python's TestCase class in
the unittest module and create a series of white box tests that will achieve branch coverage
ie between all of the unit tests, every branch in the passwordcheck function above will be
taken and not taken for the function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started