Exemple #1
0
def test_read_headers_ok():
    fpp = BytesIO(
        'abindiff 001\nfoo: 1\nbar: юни:код\n\nthis should be ignored'.encode(
            'utf-8'))

    assert patch.read_headers(fpp) == {'foo': '1', 'bar': 'юни:код'}
    assert fpp.read() == b'this should be ignored'
Exemple #2
0
def test_read_patch_ok_skip_headers():
    fpp = BytesIO(b'''abindiff 001
a: 5
b: 6

= 3 | '''.replace(b' | ', b'\n\n'))

    patch.read_headers(fpp)

    result = [
        ('h', {
            'fake': '1'
        }, None),
        ('=', {}, 3),
    ]
    result.reverse()

    for x in patch.read_patch(fpp, headers={'fake': '1'}):
        assert x == result.pop()

    assert not result
Exemple #3
0
def test_read_headers_fail_big():
    fpp = BytesIO(b'abindiff 001\na: ' + (b'0' * 65534) + b'5\n\nq')

    with pytest.raises(ValueError):
        patch.read_headers(fpp)
Exemple #4
0
def test_read_headers_fail_eof():
    fpp = BytesIO(b'abindiff 001\na: 5\nb:')

    with pytest.raises(ValueError):
        patch.read_headers(fpp)
Exemple #5
0
def test_read_headers_fail_version():
    fpp = BytesIO(b'abindiff 000\na: 5\n\n')

    with pytest.raises(ValueError):
        patch.read_headers(fpp)
Exemple #6
0
def test_read_headers_ok_empty_all():
    fpp = BytesIO(b'abindiff 001\n\n')

    assert patch.read_headers(fpp) == {}
    assert fpp.read() == b''
Exemple #7
0
def test_read_headers_ok_empty_patch():
    fpp = BytesIO(b'abindiff 001\na:5\n\n')

    assert patch.read_headers(fpp) == {'a': '5'}
    assert fpp.read() == b''