Esempio n. 1
0
 def testValidation(self):
     self.assertEqual(pulsar.validate_list((1,2)), [1,2])
     self.assertRaises(TypeError, pulsar.validate_list, 'bla')
     self.assertEqual(pulsar.validate_string(b' bla  '), 'bla')
     self.assertEqual(pulsar.validate_string(None), None)
     self.assertRaises(TypeError, pulsar.validate_string, [])
     self.assertEqual(pulsar.validate_bool(True), True)
     self.assertEqual(pulsar.validate_bool('true '), True)
     self.assertEqual(pulsar.validate_bool(' false'), False)
     self.assertRaises(TypeError, pulsar.validate_bool, [])
     self.assertRaises(ValueError, pulsar.validate_bool, 'foo')
     
     
Esempio n. 2
0
 def testValidation(self):
     self.assertEqual(pulsar.validate_list((1, 2)), [1, 2])
     self.assertRaises(TypeError, pulsar.validate_list, 'bla')
     self.assertEqual(pulsar.validate_string(' bla  '), 'bla')
     self.assertEqual(pulsar.validate_string(None), None)
     self.assertRaises(TypeError, pulsar.validate_string, [])
     self.assertEqual(pulsar.validate_bool(True), True)
     self.assertEqual(pulsar.validate_bool('true '), True)
     self.assertEqual(pulsar.validate_bool(' false'), False)
     self.assertRaises(TypeError, pulsar.validate_bool, [])
     self.assertRaises(ValueError, pulsar.validate_bool, 'foo')
     self.assertRaises(ValueError, pulsar.validate_pos_int, 'foo')
     self.assertRaises(ValueError, pulsar.validate_pos_int, -1)
     self.assertRaises(ValueError, pulsar.validate_pos_float, 'foo')
     self.assertRaises(ValueError, pulsar.validate_pos_float, -0.001)
     self.assertEqual(pulsar.validate_pos_float('0.101'), 0.101)
     self.assertRaises(TypeError, pulsar.validate_dict, 4)