Last active
July 23, 2021 18:45
-
-
Save njgibbon/d6c1498b88d3122e7a55b2e008c31423 to your computer and use it in GitHub Desktop.
test_divide_good.py
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 unittest | |
import divide | |
class TestDivide(unittest.TestCase): | |
def test_divide_pass_0(self): | |
self.assertEqual(divide.divide(10, 5), 2) | |
def test_divide_pass_1(self): | |
self.assertEqual(divide.divide(100, 10), 10) | |
def test_divide_unexpected_fail(self): | |
""" | |
We know this will throw a Runtime Error. But imagine we didn't. | |
""" | |
self.assertEqual(divide.divide(10, 0), 3) | |
def test_divide_expected_fail(self): | |
"""Correct way to test error scenarios""" | |
self.assertRaises(ZeroDivisionError, divide.divide, 8, 0) | |
if __name__ == "__main__": | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment