Testing Exercise: Choose two questions from the docstrings quiz and create a test suite (collection of test cases,
as practiced for "all fluffy" and "isteenager").
You can choose whichever testing method you like. see the examples below and we will share tomorrow.
When finished, move onto next steps of Software Dev Project
Follow @ericqweinstein's tutorial to make a Snake game using the terminal
Sample exercises from CSC108:
Read the following articles from The Hitchhiker's Guide to Python:
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO') # Edit FOO to see fail output
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
if __name__ == '__main__':
unittest.main()
def inc(x):
return x + 1
def test_answer():
assert inc(3) == 5 #Fails, since inc(3) is 4, not 5
def square(x):
"""Return the square of x.
>>> square(2)
4
>>> square(-2)
4
"""
return x * x
if __name__ == '__main__':
import doctest
doctest.testmod() # Expect no output if everything passes
Here are more thorough examples using doctest
Assignment 3: April 23 2019Submit Project Analysis and Planning phases of Software Development Project. Upload a file, Analysis_and_planning.docx, and all supporting docs to your team repo by due date
Quiz 3: TBD 2019 Python topics to Review
This work and other materials under
github.com/ICS4U-ICS4C,
are licensed under Creative Commons Attribution 4.0 Int'l License.