  class CreateCacheTableForDBCacheTests(TestCase):
      multi_db = True
  
      def test_createcachetable_observes_database_router(self):
          # cache table should not be created on 'default'
          with self.assertNumQueries(0, using='default'):
              management.call_command('createcachetable',
                                      database='default',
                                      verbosity=0, interactive=False)
 
</s> remove         old_routers = router.routers
        try:
            router.routers = [DBCacheRouter()]
            # cache table should not be created on 'default'
            with self.assertNumQueries(0, using='default'):
                management.call_command('createcachetable',
                                        database='default',
                                        verbosity=0, interactive=False)
            # cache table should be created on 'other'
            # Queries:
            #   1: check table doesn't already exist
            #   2: create savepoint (if transactional DDL is supported)
            #   3: create the table
            #   4: create the index
            #   5: release savepoint (if transactional DDL is supported)
            num = 5 if connections['other'].features.can_rollback_ddl else 3
            with self.assertNumQueries(num, using='other'):
                management.call_command('createcachetable',
                                        database='other',
                                        verbosity=0, interactive=False)
        finally:
            router.routers = old_routers
 </s> add         # cache table should not be created on 'default'
        with self.assertNumQueries(0, using='default'):
            management.call_command('createcachetable',
                                    database='default',
                                    verbosity=0, interactive=False)
        # cache table should be created on 'other'
        # Queries:
        #   1: check table doesn't already exist
        #   2: create savepoint (if transactional DDL is supported)
        #   3: create the table
        #   4: create the index
        #   5: release savepoint (if transactional DDL is supported)
        num = 5 if connections['other'].features.can_rollback_ddl else 3
        with self.assertNumQueries(num, using='other'):
            management.call_command('createcachetable',
                                    database='other',
                                    verbosity=0, interactive=False) </s> remove     def setUp(self):
        # Make the 'other' database appear to be a replica of the 'default'
        self.old_routers = router.routers
        router.routers = [MigrateNothingRouter()]

    def tearDown(self):
        # Restore the 'other' database as an independent database
        router.routers = self.old_routers

 </s> add  </s> remove     def setUp(self):
        # Make the 'other' database appear to be a replica of the 'default'
        self.old_routers = router.routers
        router.routers = [TestRouter()]

    def tearDown(self):
        # Restore the 'other' database as an independent database
        router.routers = self.old_routers

 </s> add 
    @override_settings(DATABASE_ROUTERS=[DBCacheRouter()])
  class CreateCacheTableForDBCacheTests(TestCase):
      multi_db = True
  
    @override_settings(DATABASE_ROUTERS=[DBCacheRouter()])
      def test_createcachetable_observes_database_router(self):
          # cache table should not be created on 'default'
          with self.assertNumQueries(0, using='default'):
              management.call_command('createcachetable',
                                      database='default',
                                      verbosity=0, interactive=False)
keep keep add keep keep keep keep keep keep
 Replaced router.routers usage with override_settings(DATABASE_ROUTERS); refs #23933. 
tests/cache/tests.py