def METHOD_NAME(empty_config, profile_factory, caplog):
    """Test the downgrade of schema version 8.
    Test what happens if a configuration contains a normal profile whose name starts with ``test_``. In this case, it
    should automatically rename the profile by removing the prefix, unless that name already exists, in which case an
    exception should be raised.
    """
    config = empty_config
    profile = profile_factory('test_profile', test_profile=False)
    config.add_profile(profile)
    config_migrated = downgrade_config(config.dictionary, 7)
    assert list(config_migrated['profiles'].keys()) == ['profile']
    assert 'profile `test_profile` is not a test profile but starts with' in caplog.records[0].message
    assert 'changing profile name from `test_profile` to `profile`.' in caplog.records[1].message
    profile = profile_factory('profile')
    config.add_profile(profile)
    with pytest.raises(ConfigurationError, match=r'cannot change `.*` to `.*` because it already exists.'):
        downgrade_config(config.dictionary, 7)