'Assert that the supplied reference field is identical on the expected_block and actual_block,
assoming that the references are only relative (that is, comparing only on block_type and block_id,
not course_key).'

def assertReferenceRelativelyEqual(self, reference_field, expected_block, actual_block):

    def extract_key(usage_key):
        if (usage_key is None):
            return None
        else:
            return (usage_key.block_type, usage_key.block_id)
    expected = reference_field.read_from(expected_block)
    actual = reference_field.read_from(actual_block)
    if isinstance(reference_field, Reference):
        expected = extract_key(expected)
        actual = extract_key(actual)
    elif isinstance(reference_field, ReferenceList):
        expected = [extract_key(key) for key in expected]
        actual = [extract_key(key) for key in actual]
    elif isinstance(reference_field, ReferenceValueDict):
        expected = {key: extract_key(val) for (key, val) in expected.iteritems()}
        actual = {key: extract_key(val) for (key, val) in actual.iteritems()}
    self.assertEqual(expected, actual, LazyFormat("Field    {}    doesn't    match    between    usages    {}    and    {}:    {!r}    !=    {!r}", reference_field.name, expected_block.scope_ids.usage_id, actual_block.scope_ids.usage_id, expected, actual))
