-
-
Save jasongorman/f00896c53ec36dac9ce82ab33c26a4e2 to your computer and use it in GitHub Desktop.
This file contains 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 unittest | |
from maths import sqrt | |
class SqrtTest(unittest.TestCase): | |
def test_sqrt_0(self): | |
self.assertEqual(0.0, sqrt(0.0)) | |
def test_sqrt_minus1(self): | |
self.assertRaisesRegex(Exception, | |
'Input to sqrt must be a positive number', | |
lambda: sqrt(-1)) | |
def test_sqrt_1(self): | |
self.assertEqual(1.0, sqrt(1)) | |
def test_sqrt_4(self): | |
self.assertEqual(2.0, sqrt(4.0)) | |
def test_sqrt_6point25(self): | |
self.assertEqual(2.5, sqrt(6.25)) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment