Answered step by step
Verified Expert Solution
Link Copied!

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 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions