'Patches BaseDatabaseCreation.create_test_db to not flush database'

def patch_flush_during_test_db_creation(self):

    def patch(f):
        def wrapper(*args, **kwargs):
            original_flush_command = management._commands['flush']
            try:
                management._commands['flush'] = SkipFlushCommand()
                return f(*args, **kwargs)
            finally:
                management._commands['flush'] = original_flush_command
        return wrapper
    BaseDatabaseCreation.create_test_db = patch(BaseDatabaseCreation.create_test_db)
