コード例 #1
0
    def test_adder_2(self):
        #instead of assert testing.adder(2,2) == 4
        self.assertEqual(arithmetic.adder(2, 2), 4)
        # self.assertFalse(function_name(input)) - makesure oputput is False
        # self.assertTrue(function_name(input)) - make sure output is True
        # self.assertRaises(Error_type, function, value)

    # run 'python3 -m unittest FILE_NAME.py'


# class TestStringMethods(TestCase):

#     def test_upper(self):
#         self.assertEqual('foo'.upper(), 'FOO')

#     def test_isupper(self):
#         self.assertTrue('FOO'.isupper())
#         self.assertFalse('Foo'.isupper())

#     def test_split(self):
#         s = 'hello world'
#         self.assertEqual(s.split(), ['hello', 'world'])
#         # check that s.split fails when the separator is not a string
#         with self.assertRaises(TypeError):
#             s.split(2)
コード例 #2
0
 def test_adder(self):
     assert arithmetic.adder(2, 3) == 5
コード例 #3
0
 def test_adder_2(self):
     # instead of assert arithmetic.adder(2, 2) == 4
     self.assertEqual(arithmetic.adder(2, 2), 4)
コード例 #4
0
 def test_adder_2(self):
     # use this instead of assert above
     self.assertEqual(arithmetic.adder(2, 2), 4)
     self.assertEqual(arithmetic.adder(40, 50), 90)
     self.assertEqual(arithmetic.adder(-4, -2), -6)
コード例 #5
0
 def test_adder_2(self):
     self.assertEqual(arithmetic.adder(2, 2), 4)