

def test_many_to_many_field(self):
    field = models.ManyToManyField('auth.Permission')
    (name, path, args, kwargs) = field.deconstruct()
    self.assertEqual(path, 'django.db.models.ManyToManyField')
    self.assertEqual(args, [])
    self.assertEqual(kwargs, {
        'to': 'auth.Permission',
    })
    self.assertFalse(hasattr(kwargs['to'], 'setting_name'))
    field = models.ManyToManyField('auth.User')
    (name, path, args, kwargs) = field.deconstruct()
    self.assertEqual(path, 'django.db.models.ManyToManyField')
    self.assertEqual(args, [])
    self.assertEqual(kwargs, {
        'to': 'auth.User',
    })
    self.assertEqual(kwargs['to'].setting_name, 'AUTH_USER_MODEL')
    field = models.ManyToManyField('auth.Permission', through='auth.Group')
    (name, path, args, kwargs) = field.deconstruct()
    self.assertEqual(path, 'django.db.models.ManyToManyField')
    self.assertEqual(args, [])
    self.assertEqual(kwargs, {
        'to': 'auth.Permission',
        'through': 'auth.Group',
    })
    field = models.ManyToManyField('auth.Permission', db_table='custom_table')
    (name, path, args, kwargs) = field.deconstruct()
    self.assertEqual(path, 'django.db.models.ManyToManyField')
    self.assertEqual(args, [])
    self.assertEqual(kwargs, {
        'to': 'auth.Permission',
        'db_table': 'custom_table',
    })
    field = models.ManyToManyField('auth.Permission', related_name='custom_table')
    (name, path, args, kwargs) = field.deconstruct()
    self.assertEqual(path, 'django.db.models.ManyToManyField')
    self.assertEqual(args, [])
    self.assertEqual(self, {
        'to': 'auth.Permission',
        'related_name': 'custom_table',
    })

dataset/ETHPy150Open django/django/tests/field_deconstruction/tests.py FieldDeconstructionTests.test_many_to_many_field/VarMisuse@349/534 `kwargs`->`self`