55from tests .views .fake_components import (
66 FakeAuthenticationComponent ,
77 FakeValidationComponent ,
8+ FakeValidationForm ,
89)
910
1011from django_unicorn .components import UnicornView
@@ -377,7 +378,7 @@ class TestComponent(UnicornView):
377378 class Meta :
378379 template_name = 123
379380
380- with pytest .raises (AssertionError , match = "Meta.template_name should be a str" ):
381+ with pytest .raises (AssertionError , match = r "Meta\ .template_name should be a str" ):
381382 TestComponent (component_id = "test_meta_template_name_invalid" , component_name = "test" )
382383
383384
@@ -398,9 +399,9 @@ class Meta:
398399def test_meta_template_html_invalid_type ():
399400 class TestComponent (UnicornView ):
400401 class Meta :
401- template_html = [ "<div>oops</div>" ]
402+ template_html = 123
402403
403- with pytest .raises (AssertionError , match = "Meta.template_html should be a str" ):
404+ with pytest .raises (AssertionError , match = r "Meta\ .template_html should be a str" ):
404405 TestComponent (component_id = "test_meta_template_html_invalid" , component_name = "test" )
405406
406407
@@ -414,9 +415,7 @@ class TestComponent(UnicornView):
414415 class Meta :
415416 component_key = "default-key"
416417
417- component = TestComponent (
418- component_id = "test_meta_component_key" , component_name = "test" , component_key = ""
419- )
418+ component = TestComponent (component_id = "test_meta_component_key" , component_name = "test" , component_key = "" )
420419 assert component .component_key == "default-key"
421420
422421
@@ -442,16 +441,14 @@ class TestComponent(UnicornView):
442441 class Meta :
443442 component_key = 42
444443
445- with pytest .raises (AssertionError , match = "Meta.component_key should be a str" ):
444+ with pytest .raises (AssertionError , match = r "Meta\ .component_key should be a str" ):
446445 TestComponent (component_id = "test_meta_component_key_invalid" , component_name = "test" )
447446
448447
449448# ── Meta: form_class ──────────────────────────────────────────────────────────
450449
451450
452451def test_meta_form_class_validates ():
453- from tests .views .fake_components import FakeValidationForm
454-
455452 class TestComponent (UnicornView ):
456453 template_name = "unicorn/test.html"
457454 text = "hi"
@@ -470,11 +467,6 @@ class Meta:
470467
471468def test_meta_form_class_not_in_frontend_context ():
472469 """form_class must never appear in the component's public attributes."""
473- from tests .views .fake_components import FakeValidationComponent
474470
475- component = FakeValidationComponent (
476- component_id = "test_form_class_not_in_context" , component_name = "example"
477- )
471+ component = FakeValidationComponent (component_id = "test_form_class_not_in_context" , component_name = "example" )
478472 assert "form_class" not in component ._attributes ()
479-
480-
0 commit comments