コード例 #1
0
ファイル: tests.py プロジェクト: Paul2803k/actions-tests
def test_div():
    res = main.division(4, 2)
    assert res == 2
コード例 #2
0
 def test_division(self):
     self.assertEqual(division(1, 1), 1, 'Should be 1')
     self.assertEqual(division(0, 1), 0, 'Should be 0')
     self.assertEqual(division(1, 2), 0.5, 'Should be 0.5')
コード例 #3
0
def test_division():
    assert division(2, 1) == 2.0
    assert division(1001, 1) == 1001.0
コード例 #4
0
from main import division
import unittest


class TestDivision(unittest.TestCase):
    def test_division(self):
        self.assertEqual(division(1, 1), 1, 'Should be 1')
        self.assertEqual(division(0, 1), 0, 'Should be 0')
        self.assertEqual(division(1, 2), 0.5, 'Should be 0.5')
        # with self.assertRaises(ZeroDivisionError):
        #     division(1, 0)

        # self.assertRaises(ZeroDivisionError, division, 1, 0)


if __name__ == '__main__':
    test_obj = TestDivision()
    print(test_obj.__dict__)
    test_obj.test_division()
    assert division(1, 1) == 1, 'Should be 1'
    # assert division(0, 1) == 0, 'Should be 0'
    # assert division(1, 2) == 0.5, 'Should be 0.5'
    #
    # error_message = ''
    # try:
    #     division(0, 0)
    # except Exception as e:
    #     error_message = str(e)
    # assert error_message == 'division by zero', 'Should be raise division error'
コード例 #5
0
ファイル: test_main.py プロジェクト: JaviDesu/taller_ci
def test_division():
    assert division(10, 2) == 5
    assert division(15, 3) == 5