result = util.str_to_int("1,99", round_down=False)
assert result == 2
- def test_passing_a_float_str(self):
- result = util.str_to_int("1.99")
+ @pytest.mark.parametrize("value", ['2', 2])
+ def test_passing_an_int(self, value):
+ result = util.str_to_int(value)
+ assert result == 2
+
+ @pytest.mark.parametrize("value", ['1.99', 1.99])
+ def test_passing_a_float(self, value):
+ result = util.str_to_int(value)
assert result == 1
- def test_passing_a_float_does_not_round(self):
- result = util.str_to_int("1.99", round_down=False)
+ @pytest.mark.parametrize("value", ['1.99', 1.99])
+ def test_passing_a_float_does_not_round(self, value):
+ result = util.str_to_int(value, round_down=False)
assert result == 2
def test_text_is_not_an_integer_like(self):
util.str_to_int("1.4GB")
assert str(error.value) == "Unable to convert to integer: '1.4GB'"
+ def test_input_is_not_string(self):
+ with pytest.raises(RuntimeError) as error:
+ util.str_to_int(None)
+ assert str(error.value) == "Unable to convert to integer: 'None'"
+
def true_responses(upper_casing=False):
if upper_casing: