コード例 #1
0
class TestCalc2:
    def setup(self):
        self.calc = Calc()

    # def teardown(self) -> None:
    #     print("____________________________________________________________")

    @pytest.mark.parametrize(["a", "b"], [(0, 0), (1, 3), (0.5, 0.7), (-1, 5)])
    def test_add(self, a, b):
        result = self.calc.add(a, b)
        print(result)

        # assert  4==result

    @pytest.mark.parametrize(["a", "b"], [(0, 0), (1, 3), (0.5, 0.7), (-1, 5)])
    def test_div(self, a, b):
        result = self.calc.div(a, b)
        print(result)

        # assert 3==result
    @pytest.mark.parametrize(["a", "b"], [(0, 0), (1, 3), (0.5, 0.7), (-1, 5)])
    def test_sub(self, a, b):
        result = self.calc.sub(a, b)
        print(result)

    @pytest.mark.parametrize(["a", "b"], [(0, 0), (1, 3), (0.5, 0.7), (-1, 5)])
    def test_mul(self, a, b):
        result = self.calc.mul(a, b)
        print(result)

    if __name__ == '__main__':
        pytest.main(['-vs'])
コード例 #2
0
def main():
    calc = Calc(int(input("첫번째 수 : ")),int(input("두번째 수 : ")))
    print(calc.first)
    print(calc.second)
    print("{}+{}={}".format(calc.first, calc.second, calc.sum()))
    print("{}x{}={}".format(calc.first, calc.second, calc.mul()))
    print("{}-{}={}".format(calc.first, calc.second, calc.sub()))
    print("{}/{}={}".format(calc.first, calc.second, calc.div()))
コード例 #3
0
ファイル: main.py プロジェクト: ManbokLee/tensor_1
def main():
    calc = Calc(int(input('첫번째 수: ')), int(input('두번재 수: ')))
    print(calc.first)
    print(calc.second)
    print('{} + {} = {}'.format(calc.first, calc.second, calc.sum()))
    print('{} * {} = {}'.format(calc.first, calc.second, calc.mul()))
    print('{} - {} = {}'.format(calc.first, calc.second, calc.sub()))
    print('{} / {} = {}'.format(calc.first, calc.second, calc.div()))
コード例 #4
0
ファイル: test_calc.py プロジェクト: TomaszRodzen/testowanie
def test_multiply_many_numbers():
    c = Calc()
    assert c.mul(1, 2, 3, 4, 5) == 120
コード例 #5
0
ファイル: test_calc.py プロジェクト: TomaszRodzen/testowanie
def test_multiply_two_numbers():
    c = Calc()
    assert c.mul(5, 2) == 10
コード例 #6
0
 def test_mul(self):
     c = Calc()
     assert c.mul(2,3) == 6
     assert c.mul(-1,3) == -3
コード例 #7
0
 def test_mul1(self):
     a = Calc(1,2)
     self.assertEqual(a.mul(), 2)
コード例 #8
0
 def test_mul2(self):
     b = Calc(3,4)
     self.assertEqual(b.mul(), 12)
コード例 #9
0
 def test_mul(self):
     calc = Calc()
     self.assertEqual(4, calc.mul(1, 4))
     self.assertEqual(-48, calc.mul(-8, 6))
     self.assertEqual(8, calc.mul(-2, -4))
コード例 #10
0
 try:
     choice = int(input("Enter your Choice: "))
 except:
     print("Enter the valid choice:  ")
 if choice == 1:
     n1 = float(input("Enter the 1st number to add :"))
     n2 = float(input("Enter the 2nd number to add :"))
     cal.add(n1, n2)
 if choice == 2:
     n1 = float(input("Enter the 1st number to sub :"))
     n2 = float(input("Enter the 2nd number to sub :"))
     cal.sub(n1, n2)
 if choice == 3:
     n1 = float(input("Enter the 1st number to mul :"))
     n2 = float(input("Enter the 2nd number to mul :"))
     cal.mul(n1, n2)
 if choice == 4:
     n1 = float(input("Enter the 1st number to div :"))
     n2 = float(input("Enter the 2nd number to div  :"))
     cal.div(n1, n2)
 if choice == 5:
     n = float(input("Enter a number to find its sine in radians:"))
     cal.sinrad(n)
 if choice == 6:
     n = float(input("Enter a number to find its cos in radians:"))
     cal.cosrad(n)
 if choice == 7:
     n = float(input("Enter a number to find its tan in radians:"))
     cal.tanrad(n)
 if choice == 8:
     n = float(input("Enter a number to find its cosec in radians:"))
コード例 #11
0
def main():
    calc = Calc(3, 7)
    print("{}+{}={}".format(calc.first, calc.second, calc.sum()))
    print("{}*{}={}".format(calc.first, calc.second, calc.mul()))
    print("{}-{}={}".format(calc.first, calc.second, calc.minus()))
    print("{}/{}={}".format(calc.first, calc.second, calc.div()))