- Information
- AI Chat
Was this document helpful?
7. Testing methods of python programming language
Course: Computer science1015 (CSC1015F)
257 Documents
Students shared 257 documents in this course
University: University of Cape Town
Was this document helpful?
Version 14/05/2021 14:32
Continued
CSC1015F Assignment 7: Testing
Assignment Instructions
This assignment involves constructing tests, assembling automated ‘doctest’ test scripts,
and developing and reasoning about Python programs that use input and output statements,
'if' and 'if-else' control flow statements, 'while' statements, ‘for’ statements, and
statements that perform numerical manipulation.
NOTE Your solutions to this assignment will be evaluated for correctness and for the following
qualities:
• Documentation
o Use of comments at the top of your code to identify program purpose,
author and date.
o Use of comments within your code to explain each non-obvious functional
unit of code.
• General style/readability
o The use of meaningful names for variables and functions.
• Algorithmic qualities
o Efficiency, simplicity
These criteria will be manually assessed by a tutor and commented upon. In this assignments, up to
10 marks will be deducted for deficiencies.
Question 1 [30 marks]
This question concerns devising a set of tests for a Python function that cumulatively
achieve path coverage.
The Vula page for this assignment provides a Python module called ‘numberutil.py’ as
an attachment. The module contains a function called ‘aswords’. The function accepts an
integer (0-999) as a parameter and returns the English language equivalent.
For example, aswords(905) returns the string'Nine hundred and five'.
Your task:
1. Develop a set of 8 test cases that achieve path coverage.
2. Code your tests as a doctest script suitable for execution within Wing IDE.
3. Save your doctest script as ‘testnumberutil.py’.
NOTE: make sure the docstring in your script contains a blank line before the closing “””.
(The automarker requires it.)
NOTE: the aswords() function is believed to be error free.
Question 2 [30 marks]
This question concerns devising a set of tests for a Python function that cumulatively
achieve statement coverage.
The Vula page for this assignment provides a Python module called ‘timeutil.py’ as an
attachment. The module contains a function called ‘validate’. The purpose of this
function is to accept a string value as a parameter and determine whether it is a valid
representation of a 12 hour clock reading.