66from tests .views .fake_components import (
77 FakeAuthenticationComponent ,
88 FakeValidationComponent ,
9+ FakeValidationForm ,
910)
1011
1112from django_unicorn .components import UnicornView
@@ -433,7 +434,7 @@ class TestComponent(UnicornView):
433434 class Meta :
434435 template_name = 123
435436
436- with pytest .raises (AssertionError , match = "Meta.template_name should be a str" ):
437+ with pytest .raises (AssertionError , match = r "Meta\ .template_name should be a str" ):
437438 TestComponent (component_id = "test_meta_template_name_invalid" , component_name = "test" )
438439
439440
@@ -454,9 +455,9 @@ class Meta:
454455def test_meta_template_html_invalid_type ():
455456 class TestComponent (UnicornView ):
456457 class Meta :
457- template_html = [ "<div>oops</div>" ]
458+ template_html = 123
458459
459- with pytest .raises (AssertionError , match = "Meta.template_html should be a str" ):
460+ with pytest .raises (AssertionError , match = r "Meta\ .template_html should be a str" ):
460461 TestComponent (component_id = "test_meta_template_html_invalid" , component_name = "test" )
461462
462463
@@ -470,9 +471,7 @@ class TestComponent(UnicornView):
470471 class Meta :
471472 component_key = "default-key"
472473
473- component = TestComponent (
474- component_id = "test_meta_component_key" , component_name = "test" , component_key = ""
475- )
474+ component = TestComponent (component_id = "test_meta_component_key" , component_name = "test" , component_key = "" )
476475 assert component .component_key == "default-key"
477476
478477
@@ -498,16 +497,14 @@ class TestComponent(UnicornView):
498497 class Meta :
499498 component_key = 42
500499
501- with pytest .raises (AssertionError , match = "Meta.component_key should be a str" ):
500+ with pytest .raises (AssertionError , match = r "Meta\ .component_key should be a str" ):
502501 TestComponent (component_id = "test_meta_component_key_invalid" , component_name = "test" )
503502
504503
505504# ── Meta: form_class ──────────────────────────────────────────────────────────
506505
507506
508507def test_meta_form_class_validates ():
509- from tests .views .fake_components import FakeValidationForm
510-
511508 class TestComponent (UnicornView ):
512509 template_name = "unicorn/test.html"
513510 text = "hi"
@@ -526,11 +523,6 @@ class Meta:
526523
527524def test_meta_form_class_not_in_frontend_context ():
528525 """form_class must never appear in the component's public attributes."""
529- from tests .views .fake_components import FakeValidationComponent
530526
531- component = FakeValidationComponent (
532- component_id = "test_form_class_not_in_context" , component_name = "example"
533- )
527+ component = FakeValidationComponent (component_id = "test_form_class_not_in_context" , component_name = "example" )
534528 assert "form_class" not in component ._attributes ()
535-
536-
0 commit comments