def METHOD_NAME(empty_config, profile_factory, caplog):
    """Test the downgrade of schema version 8.
    Some special care needs to be taken in the downgrade in case the profile name does not have the correct heuristics
    with respect to its ``test_profile`` value, as the profile name is interpreted in schema version 7 and lower to
    determine whether a profile is a test profile or not.
    """
    config = empty_config
    profile = profile_factory('profile', test_profile=True)
    config.add_profile(profile)
    config_migrated = downgrade_config(config.dictionary, 7)
    assert list(config_migrated['profiles'].keys()) == ['test_profile']
    assert 'profile `profile` is a test profile but does not start with' in caplog.records[0].message
    assert 'changing profile name from `profile` to `test_profile`.' in caplog.records[1].message
    profile = profile_factory('test_profile', test_profile=True)
    config.add_profile(profile)
    with pytest.raises(ConfigurationError, match=r'cannot change `.*` to `.*` because it already exists.'):
        downgrade_config(config.dictionary, 7)