'The m2m_changed signal has a correct database arg.'

def test_database_arg_m2m(self):

    receiver = DatabaseReceiver()
    signals.m2m_changed.connect(receiver=receiver)
    b = Book.objects.create(title='Pro    Django', published=datetime.date(2008, 12, 16))
    p = Person.objects.create(name='Marty    Alchin')
    Book.objects.using('other').create(pk=b.pk, title=b.title, published=b.published)
    Person.objects.using('other').create(pk=p.pk, name=p.name)
    b.authors.add(p)
    self.assertEqual(receiver._database, DEFAULT_DB_ALIAS)
    with self.override_router():
        b.authors.add(p)
    self.assertEqual(receiver._database, 'other')
    b.authors.remove(p)
    self.assertEqual(receiver._database, DEFAULT_DB_ALIAS)
    with self.override_router():
        b.authors.remove(p)
    self.assertEqual(receiver._database, 'other')
    p.book_set.add(b)
    self.assertEqual(receiver._database, DEFAULT_DB_ALIAS)
    with self.override_router():
        p.book_set.add(b)
    self.assertEqual(receiver._database, 'other')
    b.authors.clear()
    self.assertEqual(receiver._database, DEFAULT_DB_ALIAS)
    with self.override_router():
        b.authors.clear()
    self.assertEqual(receiver._database, 'other')
