Beispiel #1
0
 def test_parse_with_error(self):
     """
     L{Bool.parse} raises C{ValueError} if the given value is neither 'true'
     or 'false'.
     """
     parameter = Bool("Test")
     self.assertRaises(ValueError, parameter.parse, "0")
Beispiel #2
0
 def test_parameter_doc(self):
     """
     All L{Parameter} subclasses accept a 'doc' keyword argument.
     """
     parameters = [
         Unicode(doc="foo"),
         RawStr(doc="foo"),
         Integer(doc="foo"),
         Bool(doc="foo"),
         Enum(mapping={"hey": 1}, doc="foo"),
         Date(doc="foo"),
         List(item=Integer(), doc="foo"),
         Structure(fields={}, doc="foo")
     ]
     for parameter in parameters:
         self.assertEqual("foo", parameter.doc)
Beispiel #3
0
 def test_format(self):
     """L{Bool.format} converts the given boolean to either '0' or '1'."""
     parameter = Bool("Test")
     self.assertEqual("true", parameter.format(True))
     self.assertEqual("false", parameter.format(False))
Beispiel #4
0
 def test_parse_with_false(self):
     """L{Bool.parse} converts 'false' to C{False}."""
     parameter = Bool("Test")
     self.assertEqual(False, parameter.parse("false"))
Beispiel #5
0
 def test_parse(self):
     """L{Bool.parse} converts 'true' to C{True}."""
     parameter = Bool("Test")
     self.assertEqual(True, parameter.parse("true"))
Beispiel #6
0
 def test_format(self):
     """L{Bool.format} converts the given boolean to either '0' or '1'."""
     parameter = Bool("Test")
     self.assertEqual("true", parameter.format(True))
     self.assertEqual("false", parameter.format(False))
Beispiel #7
0
 def test_parse_with_false(self):
     """L{Bool.parse} converts 'false' to C{False}."""
     parameter = Bool("Test")
     self.assertEqual(False, parameter.parse("false"))
Beispiel #8
0
 def test_parse(self):
     """L{Bool.parse} converts 'true' to C{True}."""
     parameter = Bool("Test")
     self.assertEqual(True, parameter.parse("true"))