Did I find the right examples for you? yes no

All Samples(12)  |  Call(12)  |  Derive(0)  |  Import(0)

src/e/l/eliot-0.3.0/eliot/tests/test_validation.py   eliot(Download)
    def test_forValue(self):
        """
        L{Field.forValue} creates a L{Field} with the given key and description.
        """
        field = Field.forValue("key", None, "description")
        constructed with.
        """
        field = Field.forValue("key", 1234, "description")
        field.validate(1234)
 
        different values.
        """
        field = Field.forValue("key", 1234, "description")
        self.assertRaises(ValidationError, field.validate, 5678)
 
        code is doing things correctly.
        """
        field = Field.forValue("key", 1234, "description")
        self.assertEqual(field.serialize(None), 1234)
 
        """
        serializer = _MessageSerializer(
            [Field.forValue("message_type", "mymessage", u"The type"),
             Field("length", len, "The length of a thing"),
             ])

src/e/l/eliot-0.3.0/eliot/tests/test_output.py   eliot(Download)
        """
        serializer = _MessageSerializer(
            [Field.forValue("message_type", "mymessage", u"The type")])
        logger = MemoryLogger()
        logger.write({"message_type": "wrongtype"}, serializer)
        """
        serializer = _MessageSerializer(
            [Field.forValue("message_type", "type", u"The type"),
             Field("foo", lambda value: object(), u"The type")])
        logger = MemoryLogger()
        """
        serializer = _MessageSerializer(
            [Field.forValue("message_type", "mymessage", "The type"),
             Field("length", len, "The length")])
        messages = [{"message_type": "mymessage", "length": "abc"},
        """
        serializer = _MessageSerializer(
            [Field.forValue("message_type", "mymessage", "The type"),
             Field("length", len, "The length")])
        message = {"message_type": "mymessage", "length": "abc"}
 
        serializer = _MessageSerializer(
            [Field.forValue("message_type", "mymessage", u"The type"),
             Field("length", len, "The length of a thing"),
             ])