'Ensure that message contexts are correctly extracted for the
{% trans %} and {% blocktrans %} template tags.
Refs #14806.'

def test_template_message_context_extractor(self):

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