

def test_select_related(self):
    '\n        Boolean fields retrieved via select_related() should return booleans.\n        '
    bmt = BooleanModel.objects.create(bfield=True)
    bmf = BooleanModel.objects.create(bfield=False)
    nbmt = NullBooleanModel.objects.create(nbfield=True)
    nbmf = NullBooleanModel.objects.create(nbfield=False)
    m1 = FksToBooleans.objects.create(bf=nbmf, nbf=nbmt)
    m2 = FksToBooleans.objects.create(bf=bmf, nbf=nbmf)
    ma = FksToBooleans.objects.select_related('bf').get(pk=m1.id)
    self.assertEqual(ma.bf.bfield, True)
    self.assertEqual(ma.nbf.nbfield, True)
    mb = FksToBooleans.objects.select_related().get(pk=m1.id)
    mc = FksToBooleans.objects.select_related().get(pk=m2.id)
    self.assertEqual(mb.bf.bfield, True)
    self.assertEqual(mb.nbf.nbfield, True)
    self.assertEqual(mc.bf.bfield, False)
    self.assertEqual(mc.nbf.nbfield, False)

dataset/ETHPy150Open django/django/tests/model_fields/test_booleanfield.py BooleanFieldTests.test_select_related/VarMisuse@74/121 `bmt`->`nbmf`