'Message contexts are correctly extracted for the {% trans %} and
{% blocktrans %} template tags (#14806).'

def test_template_message_context_extractor(self):

    management.call_command('makemessages', locale=[LOCALE], verbosity=0)
    self.assertTrue(os.path.exists(self.PO_FILE))
    with open(self.PO_FILE, 'r') as fp:
        po_contents = fp.read()
        self.assertIn('msgctxt    "Special    trans    context    #1"', po_contents)
        self.assertMsgId('Translatable    literal    #7a', po_contents)
        self.assertIn('msgctxt    "Special    trans    context    #2"', po_contents)
        self.assertMsgId('Translatable    literal    #7b', po_contents)
        self.assertIn('msgctxt    "Special    trans    context    #3"', po_contents)
        self.assertMsgId('Translatable    literal    #7c', po_contents)
        for minor_part in 'abcdefgh':
            self.assertIn('msgctxt    "context    #7.1{}"'.format(minor_part), po_contents)
            self.assertMsgId('Translatable    literal    #7.1{}'.format(minor_part), po_contents)
        self.assertIn('msgctxt    "Special    blocktrans    context    #1"', po_contents)
        self.assertMsgId('Translatable    literal    #8a', po_contents)
        self.assertIn('msgctxt    "Special    blocktrans    context    #2"', po_contents)
        self.assertMsgId('Translatable    literal    #8b-singular', po_contents)
        self.assertIn('Translatable    literal    #8b-plural', po_contents)
        self.assertIn('msgctxt    "Special    blocktrans    context    #3"', po_contents)
        self.assertMsgId('Translatable    literal    #8c-singular', po_contents)
        self.assertIn('Translatable    literal    #8c-plural', po_contents)
        self.assertIn('msgctxt    "Special    blocktrans    context    #4"', po_contents)
        self.assertMsgId('Translatable    literal    #8d    %(a)s', po_contents)
