Repository: django/django
File: tests/lookup/tests.py (Python)

Code before:
            },
        )

    def test_in_bulk_values_list_fields_pk(self):
        arts = Article.objects.values_list("pk").in_bulk([self.a1.pk, self.a2.pk])
        self.assertEqual(
            arts,
            {
                self.a1.pk: (self.a1.pk,),
                self.a2.pk: (self.a2.pk,),
            },
        )

    def test_in_bulk_values_list_fields_id(self):
        arts = Article.objects.values_list("id").in_bulk([self.a1.pk, self.a2.pk])
        self.assertEqual(
            arts,
            {
                self.a1.pk: (self.a1.pk,),
                self.a2.pk: (self.a2.pk,),
            },
        )

    def test_in_bulk_values_list_named(self):
        arts = Article.objects.values_list(named=True).in_bulk([self.a1.pk, self.a2.pk])
        self.assertIsInstance(arts, dict)
        self.assertEqual(len(arts), 2)
        arts1 = arts[self.a1.pk]
        self.assertEqual(
            arts1._fields, ("pk", "id", "headline", "pub_date", "author_id", "slug")
        )
        self.assertEqual(arts1.pk, self.a1.pk)
        self.assertEqual(arts1.headline, "Article 1")
        self.assertEqual(arts1.pub_date, self.a1.pub_date)
        self.assertEqual(arts1.author_id, self.au1.pk)
        self.assertEqual(arts1.slug, "a1")

    def test_in_bulk_values_list_named_fields(self):
        arts = Article.objects.values_list("pk", "headline", named=True).in_bulk(
            [self.a1.pk, self.a2.pk]
        )
        self.assertIsInstance(arts, dict)
        self.assertEqual(len(arts), 2)
        arts1 = arts[self.a1.pk]
        self.assertEqual(arts1._fields, ("pk", "headline"))
        self.assertEqual(arts1.pk, self.a1.pk)
        self.assertEqual(arts1.headline, "Article 1")

    def test_in_bulk_values_list_flat_empty(self):
        arts = Article.objects.values_list(flat=True).in_bulk([])
        self.assertEqual(arts, {})

Review comment (suggestion):
At your option, this feels implicitly tested below just by accessing it:
```suggestion
```

Code after:
            },
        )

    def test_in_bulk_values_list_fields_pk(self):
        arts = Article.objects.values_list("pk").in_bulk([self.a1.pk, self.a2.pk])
        self.assertEqual(
            arts,
            {
                self.a1.pk: (self.a1.pk,),
                self.a2.pk: (self.a2.pk,),
            },
        )

    def test_in_bulk_values_list_fields_id(self):
        arts = Article.objects.values_list("id").in_bulk([self.a1.pk, self.a2.pk])
        self.assertEqual(
            arts,
            {
                self.a1.pk: (self.a1.pk,),
                self.a2.pk: (self.a2.pk,),
            },
        )

    def test_in_bulk_values_list_named(self):
        arts = Article.objects.values_list(named=True).in_bulk([self.a1.pk, self.a2.pk])
        self.assertIsInstance(arts, dict)
        self.assertEqual(len(arts), 2)
        arts1 = arts[self.a1.pk]
        self.assertEqual(
            arts1._fields, ("pk", "id", "headline", "pub_date", "author_id", "slug")
        )
        self.assertEqual(arts1.pk, self.a1.pk)
        self.assertEqual(arts1.headline, "Article 1")
        self.assertEqual(arts1.pub_date, self.a1.pub_date)
        self.assertEqual(arts1.author_id, self.au1.pk)
        self.assertEqual(arts1.slug, "a1")

    def test_in_bulk_values_list_named_fields(self):
        arts = Article.objects.values_list("pk", "headline", named=True).in_bulk(
            [self.a1.pk, self.a2.pk]
        )
        self.assertIsInstance(arts, dict)
        self.assertEqual(len(arts), 2)
        arts1 = arts[self.a1.pk]
        self.assertEqual(arts1._fields, ("pk", "headline"))
        self.assertEqual(arts1.pk, self.a1.pk)
        self.assertEqual(arts1.headline, "Article 1")

    def test_in_bulk_values_list_named_fields_alternative_field(self):
        arts = Article.objects.values_list("headline", named=True).in_bulk(
            [self.a1.slug, self.a2.slug], field_name="slug"