MCPcopy
hub / github.com/django/django / test_limit_choices_to_isnull_true

Method test_limit_choices_to_isnull_true

tests/admin_views/tests.py:7975–7995  ·  view source on GitHub ↗

Regression test for 20182

(self)

Source from the content-addressed store, hash-verified

7973 self.assertNotContains(response2, "Palin")
7974
7975 def test_limit_choices_to_isnull_true(self):
7976 """Regression test for 20182"""
7977 Actor.objects.create(name="Palin", age=27)
7978 Actor.objects.create(name="Kilbraken", age=50, title="Judge")
7979 response = self.client.get(reverse("admin:admin_views_sketch_add"))
7980 # Find the link
7981 m = re.search(
7982 rb'<a href="([^"]*)"[^>]* id="lookup_id_defendant1"', response.content
7983 )
7984 self.assertTrue(m) # Got a match
7985 popup_url = m[1].decode().replace("&amp;", "&")
7986
7987 # Handle relative links
7988 popup_url = urljoin(response.request["PATH_INFO"], popup_url)
7989 # Get the popup and verify the correct objects show up in the resulting
7990 # page. This step tests field__isnull=1 gets parsed correctly from the
7991 # lookup query string; in model we define defendant1 field to have a
7992 # limit_choices_to option that includes "actor__title__isnull=True".
7993 response2 = self.client.get(popup_url)
7994 self.assertNotContains(response2, "Kilbraken")
7995 self.assertContains(response2, "Palin")
7996
7997 def test_list_display_method_same_name_as_reverse_accessor(self):
7998 """

Callers

nothing calls this directly

Calls 7

reverseFunction · 0.90
searchMethod · 0.80
assertNotContainsMethod · 0.80
assertContainsMethod · 0.80
createMethod · 0.45
getMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected