'L{formatEvent} will format an event according to several rules:
- A string with no formatting instructions will be passed straight
through.
- PEP 3101 strings will be formatted using the keys and values of
the event as named fields.
- PEP 3101 keys ending with C{()} will be treated as instructions
to call that key (which ought to be a callable) before
formatting.
L{formatEvent} will always return L{unicode}, and if given bytes, will
always treat its format string as UTF-8 encoded.'

def test_formatEvent(self):

    def format(logFormat, **event):
        event['log_format'] = logFormat
        result = formatEvent(event)
        self.assertIs(type(result), unicode)
        return result
    self.assertEqual(u'', format(''))
    self.assertEqual(u'', format(u''))
    self.assertEqual(u'abc', format('{x}', x='abc'))
    self.assertEqual(u'no,    yes.', format('{not_called},    {called()}.', not_called='no', called=(lambda : 'yes')))
    self.assertEqual(u'S\xe1nchez', format('S\xc3\xa1nchez'))
    badResult = format('S\xe1nchez')
    self.assertIn(u'Unable    to    format    event', badResult)
    maybeResult = format('S{a!s}nchez', a='\xe1')
    if (not _PY3):
        self.assertIn(u'Unable    to    format    event', maybeResult)
    else:
        self.assertIn(u"Sb'\\xe1'nchez", maybeResult)
    xe1 = unicode(repr('\xe1'))
    self.assertIn(((u'S' + xe1) + 'nchez'), format('S{a!r}nchez', a='\xe1'))
