示例#1
0
    def test_root_non_number(self):
        # Messages differed in python-2.6, python-2.7-3.5, and python-3.6+
        with pytest.raises(AnsibleFilterError, match="root\\(\\) can only be used on numbers:"
                           " (invalid literal for float\\(\\): a"
                           "|could not convert string to float: a"
                           "|could not convert string to float: 'a')"):
            ms.inversepower(10, 'a')

        with pytest.raises(AnsibleFilterError, match="root\\(\\) can only be used on numbers: (a float is required|must be real number, not str)"):
            ms.inversepower('a', 10)
示例#2
0
    def test_root_non_number(self):
        with pytest.raises(
                AnsibleFilterError,
                message=
                'root() can only be used on numbers: a float is required'):
            ms.inversepower(10, 'a')

        with pytest.raises(
                AnsibleFilterError,
                message=
                'root() can only be used on numbers: a float is required'):
            ms.inversepower('a', 10)
示例#3
0
    def test_root_non_number(self):
        # Message changed in python3.6
        with pytest.raises(AnsibleFilterError,
                           match="root\\(\\) can only be used on numbers:"
                           " (could not convert string to float: a"
                           "|could not convert string to float: 'a')"):
            ms.inversepower(10, 'a')

        with pytest.raises(
                AnsibleFilterError,
                match=
                "root\\(\\) can only be used on numbers: (a float is required|must be real number, not str)"
        ):
            ms.inversepower('a', 10)
示例#4
0
 def test_cube_root(self):
     assert ms.inversepower(27, 3) == 3
示例#5
0
 def test_square_root(self):
     assert ms.inversepower(100) == 10
     assert ms.inversepower(100, 2) == 10
示例#6
0
 def test_cube_root(self):
     assert ms.inversepower(27, 3) == 3
示例#7
0
 def test_square_root(self):
     assert ms.inversepower(100) == 10
     assert ms.inversepower(100, 2) == 10
示例#8
0
    def test_root_non_number(self):
        with pytest.raises(AnsibleFilterError, message='root() can only be used on numbers: a float is required'):
            ms.inversepower(10, 'a')

        with pytest.raises(AnsibleFilterError, message='root() can only be used on numbers: a float is required'):
            ms.inversepower('a', 10)