@@ -110,6 +110,31 @@ def test_text_sanitizer_no_settings(self):
110110 self .assertContains (response , "<span>some text</span>" )
111111
112112
113+ @skipIf (SKIP_CMS_TEST , "Skipping tests because djangocms is not installed" )
114+ class WidgetConfigurationTestCase (BaseTestCase ):
115+ def test_htmlfield_configuration_without_text_editor_settings (self ):
116+ """Regression test for #136: HTMLField(configuration=...) should not
117+ raise AttributeError when TEXT_EDITOR_SETTINGS is not in Django settings."""
118+ from django .conf import settings
119+ from djangocms_text .widgets import TextEditorWidget
120+
121+ # Ensure TEXT_EDITOR_SETTINGS is not set in Django settings
122+ has_setting = hasattr (settings , "TEXT_EDITOR_SETTINGS" )
123+ if has_setting :
124+ original = settings .TEXT_EDITOR_SETTINGS
125+ delattr (settings , "TEXT_EDITOR_SETTINGS" )
126+
127+ # Define a custom configuration in Django settings
128+ settings .MY_CUSTOM_CONFIG = {"toolbar" : "HTMLField" }
129+ try :
130+ widget = TextEditorWidget (configuration = "MY_CUSTOM_CONFIG" )
131+ self .assertEqual (widget .configuration ["toolbar" ], "HTMLField" )
132+ finally :
133+ del settings .MY_CUSTOM_CONFIG
134+ if has_setting :
135+ settings .TEXT_EDITOR_SETTINGS = original
136+
137+
113138@skipIf (not SKIP_CMS_TEST , "Skipping tests because djangocms is installed" )
114139class NonCMSWidgetTestCase (BaseTestCase ):
115140 def test_django_form_renders_widget (self ):
0 commit comments