Last active
June 23, 2018 16:11
-
-
Save iafisher/663c0a85b1e51f10ad7a9570159a1d5c to your computer and use it in GitHub Desktop.
A demo of a testing utility for the Python shell that automatically generates unit tests based on your interactive session
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
>>> import mylib, testhelper as th | |
>>> fibonacci = th.register(mylib.fibonacci) | |
>>> fib(12) | |
144 | |
[testhelper] Is this the expected result (y[es]/n[o]/c[ancel])? y | |
>>> fib(-1) | |
Traceback (most recent call last): | |
... | |
ValueError | |
[testhelper] Is this the expected result (y[es]/n[o]/c[ancel])? y | |
>>> print(th.compile()) | |
import unittest | |
import mylib | |
class MyTestCase(unittest.TestCase): | |
def test_all(self): | |
self.assertEqual(mylib.fib(12), 144) | |
with self.assertRaises(ValueError): | |
mylib.fib(-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment