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")
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)
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))
def test_parse_with_false(self): """L{Bool.parse} converts 'false' to C{False}.""" parameter = Bool("Test") self.assertEqual(False, parameter.parse("false"))
def test_parse(self): """L{Bool.parse} converts 'true' to C{True}.""" parameter = Bool("Test") self.assertEqual(True, parameter.parse("true"))