Created
September 19, 2015 06:18
-
-
Save iankronquist/34b3c25ada59b6241685 to your computer and use it in GitHub Desktop.
An example of testing in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib (a, b, max ): | |
while (b < max): | |
tmp = a | |
a = b | |
b = a + b | |
return b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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