예제 #1
0
 def test_getter_valid_strict(self):
     """
     Ensure that the Float getter returns an float without error - strict mode
     """
     from crushinator.toolkit.probes import Float
     
     probe = Float('probe', strict=True)
     
     for float_ in valid_floats_strict:
         probe.value = float_
         self.assertTrue(isinstance(probe.value, (float)), "%s is not a float" % float_)
예제 #2
0
 def test_getter_valid(self):
     """
     Ensure that the Float getter returns an float without error
     given each of the known numeric literals
     """
     from crushinator.toolkit.probes import Float
     
     probe = Float('probe')
     
     for float_ in valid_floats_nostrict:
         probe.value = float_
         self.assertTrue(isinstance(probe.value, (float)), "%s is not a float" % float_)
예제 #3
0
 def test_getter_invalid_strict(self):
     """
     Ensure that the Float getter fails when passed integers and strict is false.
     """
     from crushinator.toolkit.probes import Float
     
     probe = Float('probe', strict=True)
     
     for float_ in invalid_floats_strict:
         probe.value = float_
         try:
             x = probe.value
         except ValueError:
             pass
         else:
             self.fail("%s did not raise ValueError, coverted to %s" % (float_, x))
예제 #4
0
 def test_getter_invalid(self):
     """
     Ensure that the Float getter throws a ValueError for any improper values
     """
     from crushinator.toolkit.probes import Float
     import sys
     
     probe = Float('probe')
     
     for float_ in invalid_floats_nostrict:
         probe.value = float_
         try:
             x = probe.value
         except ValueError:
             pass
         else:
             self.fail("%s did not raise ValueError, coverted to %s" % (float_, x))