Question: 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 black-box 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 10 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 uppercase/lowercase
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 password_check(password):
if not isinstance (password, str):
raise TypeError("password must be a string")
if len(password)10 :
raise ValueError("password must be at least 10 characters long")
lower_count, upper_count, number_count, special_count =0
for char in password:
if char in "abcdefghijklmnopqrstuvwxyz":
lower_count +=1
elif char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
upper_count +=1
elif char in "1234567890":
number_count +=1
elif char in "!!#%&& ()"
special_count +=1
else:
raise ValueError("password cannot contain illegal character: ", char)
if lower_count ==0 :
raise ValueError("password must contain at least 1 lowercase character")
if upper_count ==0 :
raise ValueError("password must contain at least 1 uppercase character")
if number_count == :
raise ValueError("password must contain at least 1 number character")
if special_count ==0 :
raise ValueError("password must contain at least 1 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
(i.e., between all of the unit tests, every branch in the password_check function above will be
taken and not taken) for the function.
 Assignment Instructions For this assignment you will be writing unit tests

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 Databases Questions!