Пример #1
0
    def test_square_root(self):
        test = sm(-4)
        with raises(ValueError) as exception:
            test.square_root()

        for num in np.arange(5):
            test = sm(num)
            assert test.square_root() == np.sqrt(num)
Пример #2
0
    def test_factorial(self):
        test = sm(-4)
        with raises(ValueError) as exception:
            test.factorial()

        for num in range(5):
            test = sm(num)
            assert test.factorial() == math.factorial(num)
Пример #3
0
    def test_odd_or_even(self):
        for num in np.arange(0, 12, 2):
            test = sm(num)
            assert test.odd_or_even() == 'Even'

        for num in np.arange(1, 11, 2):
            test = sm(num)
            assert test.odd_or_even() == 'Odd'
Пример #4
0
    def test_power(self):
        test = sm(3)
        with raises(ValueError) as exception:
            test.power(False)

        for num in range(5):
            test = sm(num)
            for x in np.arange(4):
                assert test.power(x) == math.pow(num, x)
Пример #5
0
 def test_constructor_input_float(self):
     with raises(ValueError) as exception:
         test = sm(0.1)
Пример #6
0
 def test_square(self):
     for num in range(5):
         test = sm(num)
         assert test.square() == np.square(num)
Пример #7
0
 def test_constructor_input_boolean(self):
     with raises(ValueError) as exception:
         test = sm(False)
Пример #8
0
 def test_constructor_input_complex(self):
     with raises(ValueError) as exception:
         test = sm(2j)
Пример #9
0
 def test_constructor_input_string(self):
     with raises(ValueError) as exception:
         test = sm('a')