from django.test import TestCase


class MigrationsCheck(TestCase):
    def setUp(self):
        from django.utils import translation
        self.saved_locale = translation.get_language()
        translation.deactivate_all()

    def tearDown(self):
        if self.saved_locale is not None:
            from django.utils import translation
            translation.activate(self.saved_locale)

    def test_missing_migrations(self):
        from django.db import connection
        from django.apps.registry import apps
        from django.db.migrations.executor import MigrationExecutor
        executor = MigrationExecutor(connection)
        from django.db.migrations.autodetector import MigrationAutodetector
        from django.db.migrations.state import ProjectState
        autodetector = MigrationAutodetector(
            executor.loader.project_state(),
            ProjectState.from_apps(apps),
        )
        changes = autodetector.changes(graph=executor.loader.graph)
        self.assertEqual({}, changes)

from django.apps.registry import apps
from django.db import connection
from django.db.migrations.autodetector import MigrationAutodetector
from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.state import ProjectState
from django.test import TestCase
from django.utils import translation


class MigrationsCheck(TestCase):
    def setUp(self):
        self.saved_locale = translation.get_language()
        translation.deactivate_all()

    def tearDown(self):
        if self.saved_locale is not None:
            translation.activate(self.saved_locale)

    def test_missing_migrations(self):
        executor = MigrationExecutor(connection)
        autodetector = MigrationAutodetector(
            executor.loader.project_state(),
            ProjectState.from_apps(apps),
        )

        changes = autodetector.changes(graph=executor.loader.graph)

        self.assertEqual({}, changes)

Clean up database test case imports
Clean up database test case imports

Signed-off-by: Aleksi Häkli <44cb6a94c0d20644d531e2be44779b52833cdcd2@iki.fi>

+ from django.apps.registry import apps
+ from django.db import connection
+ from django.db.migrations.autodetector import MigrationAutodetector
+ from django.db.migrations.executor import MigrationExecutor
+ from django.db.migrations.state import ProjectState
  from django.test import TestCase
+ from django.utils import translation
  
  
  class MigrationsCheck(TestCase):
      def setUp(self):
-         from django.utils import translation
          self.saved_locale = translation.get_language()
          translation.deactivate_all()
  
      def tearDown(self):
          if self.saved_locale is not None:
-             from django.utils import translation
              translation.activate(self.saved_locale)
  
      def test_missing_migrations(self):
-         from django.db import connection
-         from django.apps.registry import apps
-         from django.db.migrations.executor import MigrationExecutor
          executor = MigrationExecutor(connection)
-         from django.db.migrations.autodetector import MigrationAutodetector
-         from django.db.migrations.state import ProjectState
          autodetector = MigrationAutodetector(
              executor.loader.project_state(),
              ProjectState.from_apps(apps),
          )
+ 
          changes = autodetector.changes(graph=executor.loader.graph)
+ 
          self.assertEqual({}, changes)
  
Clean up database test case imports
## Code Before:
from django.test import TestCase


class MigrationsCheck(TestCase):
    def setUp(self):
        from django.utils import translation
        self.saved_locale = translation.get_language()
        translation.deactivate_all()

    def tearDown(self):
        if self.saved_locale is not None:
            from django.utils import translation
            translation.activate(self.saved_locale)

    def test_missing_migrations(self):
        from django.db import connection
        from django.apps.registry import apps
        from django.db.migrations.executor import MigrationExecutor
        executor = MigrationExecutor(connection)
        from django.db.migrations.autodetector import MigrationAutodetector
        from django.db.migrations.state import ProjectState
        autodetector = MigrationAutodetector(
            executor.loader.project_state(),
            ProjectState.from_apps(apps),
        )
        changes = autodetector.changes(graph=executor.loader.graph)
        self.assertEqual({}, changes)

## Instruction:
Clean up database test case imports
## Code After:
from django.apps.registry import apps
from django.db import connection
from django.db.migrations.autodetector import MigrationAutodetector
from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.state import ProjectState
from django.test import TestCase
from django.utils import translation


class MigrationsCheck(TestCase):
    def setUp(self):
        self.saved_locale = translation.get_language()
        translation.deactivate_all()

    def tearDown(self):
        if self.saved_locale is not None:
            translation.activate(self.saved_locale)

    def test_missing_migrations(self):
        executor = MigrationExecutor(connection)
        autodetector = MigrationAutodetector(
            executor.loader.project_state(),
            ProjectState.from_apps(apps),
        )

        changes = autodetector.changes(graph=executor.loader.graph)

        self.assertEqual({}, changes)
