Skip to content

Instantly share code, notes, and snippets.

@iankronquist
Created September 19, 2015 06:18
Show Gist options
  • Save iankronquist/34b3c25ada59b6241685 to your computer and use it in GitHub Desktop.
Save iankronquist/34b3c25ada59b6241685 to your computer and use it in GitHub Desktop.
An example of testing in python
def fib (a, b, max ):
while (b < max):
tmp = a
a = b
b = a + b
return b
# To install a test runner, $ pip install trial
# To run this test, $ trial fib_test.py
import unittest
from fib import fib
class TestFib(unittest.TestCase):
def test_fib(self):
self.assertEqual(fib(1, 1, 2), 2)
self.assertEqual(fib(1, 1, 5), 5)
self.assertEqual(fib(1, 1, 7), 8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment