Repository: django/django
File: tests/model_fields/test_jsonfield.py (Python)

Code before:
        )
        self.assertSequenceEqual(qs, [self.objs[4]])

    def test_key_text_transform_from_lookup_invalid(self):
        msg = "Lookup must contain key or index transforms."
        with self.assertRaisesMessage(ValueError, msg):
            KT("value")
        with self.assertRaisesMessage(ValueError, msg):
            KT("")

    def test_literal_annotation_filtering(self):
        all_objects = NullableJSONModel.objects.order_by("id")
        qs = all_objects.annotate(data=Value({"foo": "bar"}, JSONField())).filter(
            data__foo="bar"
        )
        self.assertQuerySetEqual(qs, all_objects)


class JSONNullTests(TestCase):
    def test_repr(self):
        self.assertEqual(repr(JSONNull()), "JSONNull()")

    def test_save_load(self):
        obj = NullableJSONModel(value=JSONNull())
        obj.save()
        obj.refresh_from_db()
        self.assertIsNone(obj.value)

    def test_create(self):
        obj = NullableJSONModel.objects.create(value=JSONNull())
        obj.refresh_from_db()
        self.assertIsNone(obj.value)

    def test_update(self):
        obj = NullableJSONModel.objects.create(value={"key": "value"})
        NullableJSONModel.objects.update(value=JSONNull())
        obj.refresh_from_db()
        self.assertIsNone(obj.value)

    def test_filter(self):
        obj = NullableJSONModel.objects.create(value=JSONNull())
        found = NullableJSONModel.objects.get(value=JSONNull())
        self.assertEqual(obj, found)
        self.assertSequenceEqual(
            NullableJSONModel.objects.exclude(value=JSONNull()), []
        )
        self.assertSequenceEqual(
            NullableJSONModel.objects.filter(value__isnull=True), []
        )

    def test_case_expression(self):

Review comment (suggestion):
Thanks to #19285 we can drop these calls, at least for the top level.

```suggestion
```

Code after:
    def test_key_text_transform_from_lookup(self):
        qs = NullableJSONModel.objects.annotate(b=KT("value__bax__foo")).filter(
            b__contains="ar",
        )
        self.assertSequenceEqual(qs, [self.objs[7]])
        qs = NullableJSONModel.objects.annotate(c=KT("value__o")).filter(
            c__contains="uot",
        )
        self.assertSequenceEqual(qs, [self.objs[4]])

    def test_key_text_transform_from_lookup_invalid(self):
        msg = "Lookup must contain key or index transforms."
        with self.assertRaisesMessage(ValueError, msg):
            KT("value")
        with self.assertRaisesMessage(ValueError, msg):
            KT("")

    def test_literal_annotation_filtering(self):
        all_objects = NullableJSONModel.objects.order_by("id")
        qs = all_objects.annotate(data=Value({"foo": "bar"}, JSONField())).filter(
            data__foo="bar"
        )
        self.assertQuerySetEqual(qs, all_objects)


@skipUnlessDBFeature("supports_primitives_in_json_field")
class JSONNullTests(TestCase):
    def test_repr(self):
        self.assertEqual(repr(JSONNull()), "JSONNull()")

    def test_save_load(self):
        obj = JSONModel(value=JSONNull())
        obj.save()
        self.assertIsNone(obj.value)

    def test_create(self):
        obj = JSONModel.objects.create(value=JSONNull())
        self.assertIsNone(obj.value)

    def test_update(self):
        obj = JSONModel.objects.create(value={"key": "value"})
        JSONModel.objects.update(value=JSONNull())
        obj.refresh_from_db()
        self.assertIsNone(obj.value)

    def test_filter(self):
        json_null = NullableJSONModel.objects.create(value=JSONNull())
        sql_null = NullableJSONModel.objects.create(value=None)
        self.assertSequenceEqual(
            [json_null], NullableJSONModel.objects.filter(value=JSONNull())
        )