Fixed #24812 -- Fixed app registry RuntimeWarnings in schema and migrations tests.
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 75d5dd619b089..03dfae7903b6e 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -868,6 +868,9 @@ class FakeSMTPServer(smtpd.SMTPServer, threading.Thread):
 
     def __init__(self, *args, **kwargs):
         threading.Thread.__init__(self)
+        # New kwarg added in Python 3.5; default switching to False in 3.6.
+        if sys.version_info >= (3, 5):
+            kwargs['decode_data'] = True
         smtpd.SMTPServer.__init__(self, *args, **kwargs)
         self._sink = []
         self.active = False
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py
index 58bf18921a238..3c6abe3a913ee 100644
--- a/tests/migrations/test_state.py
+++ b/tests/migrations/test_state.py
@@ -396,17 +396,22 @@ def test_add_relations(self):
         #24573 - Adding relations to existing models should reload the
         referenced models too.
         """
+        new_apps = Apps()
+
         class A(models.Model):
             class Meta:
                 app_label = 'something'
+                apps = new_apps
 
         class B(A):
             class Meta:
                 app_label = 'something'
+                apps = new_apps
 
         class C(models.Model):
             class Meta:
                 app_label = 'something'
+                apps = new_apps
 
         project_state = ProjectState()
         project_state.add_model(ModelState.from_model(A))
@@ -447,15 +452,19 @@ def test_remove_relations(self):
         #24225 - Tests that relations between models are updated while
         remaining the relations and references for models of an old state.
         """
+        new_apps = Apps()
+
         class A(models.Model):
             class Meta:
                 app_label = "something"
+                apps = new_apps
 
         class B(models.Model):
             to_a = models.ForeignKey(A)
 
             class Meta:
                 app_label = "something"
+                apps = new_apps
 
         def get_model_a(state):
             return [mod for mod in state.apps.get_models() if mod._meta.model_name == 'a'][0]
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index de38f6db9494f..ba20a8a9acb6f 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -765,8 +765,10 @@ class Meta:
                 app_label = 'schema'
                 apps = new_apps
 
-        self.local_models = [LocalBookWithM2M]
-
+        self.local_models = [
+            LocalBookWithM2M,
+            LocalBookWithM2M._meta.get_field('tags').remote_field.through,
+        ]
         # Create the tables
         with connection.schema_editor() as editor:
             editor.create_model(Author)
@@ -845,6 +847,7 @@ class Meta:
         # Create an M2M field
         new_field = M2MFieldClass("schema.TagM2MTest", related_name="authors")
         new_field.contribute_to_class(LocalAuthorWithM2M, "tags")
+        self.local_models += [new_field.remote_field.through]
         # Ensure there's no m2m table there
         self.assertRaises(DatabaseError, self.column_classes, new_field.remote_field.through)
         # Add the field
@@ -934,7 +937,10 @@ class Meta:
                 app_label = 'schema'
                 apps = new_apps
 
-        self.local_models = [LocalBookWithM2M]
+        self.local_models = [
+            LocalBookWithM2M,
+            LocalBookWithM2M._meta.get_field('tags').remote_field.through,
+        ]
 
         # Create the tables
         with connection.schema_editor() as editor:
@@ -955,6 +961,7 @@ class Meta:
         old_field = LocalBookWithM2M._meta.get_field("tags")
         new_field = M2MFieldClass(UniqueTest)
         new_field.contribute_to_class(LocalBookWithM2M, "uniques")
+        self.local_models += [new_field.remote_field.through]
         with connection.schema_editor() as editor:
             editor.alter_field(LocalBookWithM2M, old_field, new_field)
         # Ensure old M2M is gone

https://code.djangoproject.com/ticket/24812
