예제 #1
0
 def test_non_integers_are_valuerror(self, value):
     """Values that cannot be coerced to an integer are rejected with a
     `ValueError`."""
     assume(not value.strip().isdigit())
     with pytest.raises(ValueError) as exc:
         cli.check_positive_integer(name='test', value=value)
     assert 'should be an integer' in exc.value.args[0]
예제 #2
0
 def test_non_positive_integers_are_valueerror(self, value):
     """Negative or zero integers are rejected with a `ValueError`."""
     with pytest.raises(ValueError) as exc:
         cli.check_positive_integer(name='test', value=value)
     assert 'should be positive' in exc.value.args[0]
예제 #3
0
 def test_positive_integers_are_allowed(self, value):
     """Positive integers go through `check_positive_integer` unmodified."""
     assert cli.check_positive_integer(name='test', value=value) == value