'Warnings emitted before L{TestCase.assertWarns} is called do not get
flushed and do not alter the behavior of L{TestCase.assertWarns}.'

def test_assertWarnsAfterUnassertedWarning(self):

    class TheWarning(Warning, ):
        pass
    def f(message):
        warnings.warn(message, category=TheWarning)
    f('foo')
    self.assertWarns(TheWarning, 'bar', __file__, f, 'bar')
    [warning] = self.flushWarnings([f])
    self.assertEqual(warning['message'], 'foo')
