@@ -48,11 +48,16 @@ def test_initial_form_class(self):
4848 assert "my-class" in widget .render ("name" , None )
4949 assert "django-select2" in widget .render ("name" , None )
5050
51- @pytest .mark .parametrize ("code,name" , SELECT2_TRANSLATIONS .items ())
52- def test_lang_attr (self , code , name ):
53- translation .activate (code )
54- widget = self .widget_cls ()
55- assert f'lang="{ name } "' in widget .render ("name" , None )
51+ def test_lang_attr (self ):
52+ with translation .override ('de' ):
53+ widget = Select2Widget ()
54+ assert f'lang="de"' in widget .render ("name" , None )
55+
56+ # Regression test for #163
57+ widget = Select2Widget ()
58+ assert widget .i18n_name == "en"
59+ with translation .override ("de" ):
60+ assert widget .i18n_name == "de"
5661
5762 def test_allow_clear (self , db ):
5863 required_field = self .form .fields ["artist" ]
@@ -258,11 +263,10 @@ def test_initial_form_class(self):
258263 "name" , None
259264 )
260265
261- @pytest .mark .parametrize ("code,name" , SELECT2_TRANSLATIONS .items ())
262- def test_lang_attr (self , code , name ):
263- translation .activate (code )
264- widget = self .widget_cls (data_view = "heavy_data_1" )
265- assert f'lang="{ name } "' in widget .render ("name" , None )
266+ def test_lang_attr (self ):
267+ with translation .override ('fr' ):
268+ widget = self .widget_cls (data_view = "heavy_data_1" )
269+ assert f'lang="fr"' in widget .render ("name" , None )
266270
267271 def test_selected_option (self , db ):
268272 not_required_field = self .form .fields ["primary_genre" ]
0 commit comments