'Ensure that QuerySet.only only returns the requested fields.'

def test_only(self):

    person = self.Person(name='test', age=25)
    person.save()
    obj = self.Person.objects.only('name').get()
    self.assertEqual(obj.name, person.name)
    self.assertEqual(obj.age, None)
    obj = self.Person.objects.only('age').get()
    self.assertEqual(obj.name, None)
    self.assertEqual(obj.age, person.age)
    obj = self.Person.objects.only('name', 'age').get()
    self.assertEqual(obj.name, person.name)
    self.assertEqual(obj.age, person.age)
    obj = self.Person.objects.only(*('id', 'name')).get()
    self.assertEqual(obj.name, person.name)
    self.assertEqual(obj.age, None)
    class Employee(self.Person, ):
        salary = IntField(db_field='wage')
    employee = Employee(name='test    employee', age=40, salary=30000)
    employee.save()
    obj = self.Person.objects(id=employee.id).only('age').get()
    self.assertTrue(isinstance(obj, Employee))
    obj = Employee.objects(id=employee.id).only('salary').get()
    self.assertEqual(obj.salary, employee.salary)
    self.assertEqual(obj.name, None)
