def _record_duplicate_testcase(duplicate):
    original = (
        TestCase.query
        .filter_by(job_id=duplicate.job_id, name_sha=duplicate.name_sha)
        .with_for_update().first()
        )

    prefix = _DUPLICATE_TEST_COMPLAINT
    if (original.message is None) or not original.message.startswith(prefix):
        original.message = '{}{}\n'.format(prefix, original.step.label)
        original.result = Result.failed

    if duplicate.step.label not in original.message:
        original.message += '{}\n'.format(duplicate.step.label)

    return original
Find the TestCase that already exists for `duplicate` and update it.
dataset/ETHPy150Open dropbox/changes/changes/models/testresult.py/_record_duplicate_testcase