Skip to content

Commit c94160b

Browse files
committed
Add in a test to show the default country is correctly selected
1 parent 6bf01a9 commit c94160b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

django_countries/tests/test_fields.py

+6
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,12 @@ def test_no_blank_choice(self):
629629
form.fields["favourite_country"].choices[0], ("AF", "Afghanistan")
630630
)
631631

632+
def test_selected_default(self):
633+
form = forms.PersonForm()
634+
self.assertEqual(form.fields["favourite_country"].initial, "NZ")
635+
html = str(form["favourite_country"])
636+
self.assertIn('<option value="NZ" selected>', html)
637+
632638
def test_blank_choice_label(self):
633639
form = forms.AllowNullForm()
634640
self.assertEqual(form.fields["country"].choices[0], ("", "(select country)"))

0 commit comments

Comments
 (0)