Exemple #1
0
def test_compares_large_files():
    # The current buffer used by ``cmp_contents`` is 8192 bytes; make sure
    # we can detect differences beyond the end of the first buffer.
    common_prefix = b"padding123" * 8200

    f1 = io.BytesIO(common_prefix + b"1")
    f2 = io.BytesIO(common_prefix + b"2")

    assert not filecmp2.cmp_contents(f1=f1, f2=f2)
Exemple #2
0
def test_mixed_binary_and_text_objects_are_different():
    f1 = io.BytesIO(b"hello world")
    f2 = io.StringIO(u"hello world")

    assert not filecmp2.cmp_contents(f1, f2)
Exemple #3
0
def test_can_compare_equal_file_like_objects():
    f1 = io.BytesIO(b"hello world")
    f2 = io.BytesIO(b"hello world")

    assert filecmp2.cmp_contents(f1, f2)
Exemple #4
0
def test_can_compare_equal_file_like_objects_which_are_text():
    f1 = io.StringIO(u"hello world")
    f2 = io.StringIO(u"hello world")

    assert filecmp2.cmp_contents(f1, f2)
Exemple #5
0
def test_comparing_contents_of_file_object_to_itself():
    f = io.BytesIO(b"hello world")

    with pytest.raises(ValueError, match="f1 and f2 are the same stream"):
        filecmp2.cmp_contents(f, f)