@@ -30,6 +30,30 @@ def test_extract_simple_single_quotes(self):
3030 messages = list (extract_django (buf , default_keys , [], {}))
3131 self .assertEqual ([(1 , None , u'Bunny' , [])], messages )
3232
33+ def test_extract_simple_with_context_single_quotes (self ):
34+ buf = BytesIO (b"{% trans 'Bunny' context 'carrot' %}" )
35+ messages = list (extract_django (buf , default_keys , [], {}))
36+ self .assertEqual ([(1 , 'pgettext' ,
37+ [u'carrot' , u'Bunny' ], [])], messages )
38+
39+ def test_extract_simple_with_context_double_quotes (self ):
40+ buf = BytesIO (b"{% trans 'Bunny' context \" carrot\" %}" )
41+ messages = list (extract_django (buf , default_keys , [], {}))
42+ self .assertEqual ([(1 , 'pgettext' ,
43+ [u'carrot' , u'Bunny' ], [])], messages )
44+
45+ def test_extract_simple_with_context_with_single_quotes (self ):
46+ buf = BytesIO (b"{% trans 'Bunny' context \" 'carrot'\" %}" )
47+ messages = list (extract_django (buf , default_keys , [], {}))
48+ self .assertEqual ([(1 , 'pgettext' ,
49+ [u'\' carrot\' ' , u'Bunny' ], [])], messages )
50+
51+ def test_extract_simple_with_context_with_double_quotes (self ):
52+ buf = BytesIO (b"{% trans 'Bunny' context '\" carrot\" ' %}" )
53+ messages = list (extract_django (buf , default_keys , [], {}))
54+ self .assertEqual ([(1 , 'pgettext' ,
55+ [u'"carrot"' , u'Bunny' ], [])], messages )
56+
3357 def test_extract_var (self ):
3458 buf = BytesIO (b'{% blocktrans %}{{ anton }}{% endblocktrans %}' )
3559 messages = list (extract_django (buf , default_keys , [], {}))
0 commit comments