コード例 #1
0
def test_same_reference():
    a = [1, 2, 3, 4]
    b = a
    # shallow copy (do not change original), alternatively use the copy module
    c = a[:]
    assert check_equality(a, b) == Equality.SAME_REFERENCE
    assert check_equality(a, c) != Equality.SAME_REFERENCE
コード例 #2
0
def test_not_same():
    a = [1, 2, 3]
    b = [4, 5, 6]
    assert check_equality(a, b) == Equality.NO_EQUALITY
コード例 #3
0
def test_same_unordered():
    a = [1, 2, 3, 4]
    b = a[::-1]
    c = b[:] + [5]
    assert check_equality(a, b) == Equality.SAME_UNORDERED
    assert check_equality(a, c) != Equality.SAME_UNORDERED
コード例 #4
0
def test_same_unordered_deduped():
    a = [1, 2, 2, 3, 4]
    b = a[:] + [1, 3, 4, 4]
    c = b[:] + [5]
    assert check_equality(a, b) == Equality.SAME_UNORDERED_DEDUPED
    assert check_equality(a, c) != Equality.SAME_UNORDERED_DEDUPED
コード例 #5
0
def test_same_ordered():
    a = [1, 2, 3, 4]
    b = a[:]
    c = a
    assert check_equality(a, b) == Equality.SAME_ORDERED
    assert check_equality(a, c) != Equality.SAME_ORDERED  # SAME_REFERENCE