コード例 #1
0
ファイル: test.py プロジェクト: kwamenum86/nibble
def test():
    """Ensure that calling the buffer is not "flushed" between put calls"""
    n = Writer(filepath)
    byte_count = 0
    n.put_data([10, 10], item_size=5)
    n.put_data([10, 10], item_size=5)
    n._flush_buffer()
    n.close()
    fh = open(filepath, "rb")
    for byte in fh.read():
        byte_count += 1
    fh.close()
    os.remove(filepath)
    return byte_count == 3
コード例 #2
0
ファイル: test.py プロジェクト: xl9211/nibble
def test():
    """Ensure that calling the buffer is not "flushed" between put calls"""
    n = Writer(filepath)
    byte_count = 0
    n.put_data([10, 10], item_size=5)
    n.put_data([10, 10], item_size=5)
    n._flush_buffer()
    n.close()
    fh = open(filepath, "rb")
    for byte in fh.read():
        byte_count += 1
    fh.close()
    os.remove(filepath)
    return byte_count == 3
コード例 #3
0
ファイル: test.py プロジェクト: kwamenum86/nibble
def test():
    """Basic test to ensure that writing 5 bits at a time works as expected"""
    n = Writer(filepath)
    data_good = True
    test_bytes = [74, 82, 144]
    byte_index = 0
    n.put_data([9, 9, 9, 9], item_size=5)
    n._flush_buffer()
    n.close()
    fh = open(filepath, "rb")
    for byte in fh.read():
        data_good &= ord(byte) == test_bytes[byte_index]
        if not data_good:
            break
        byte_index += 1
    fh.close()
    os.remove(filepath)
    return data_good
コード例 #4
0
ファイル: test.py プロジェクト: xl9211/nibble
def test():
    """Basic test to ensure that writing 5 bits at a time works as expected"""
    n = Writer(filepath)
    data_good = True
    test_bytes = [74, 82, 144]
    byte_index = 0
    n.put_data([9, 9, 9, 9], item_size=5)
    n._flush_buffer()
    n.close()
    fh = open(filepath, "rb")
    for byte in fh.read():
        data_good &= ord(byte) == test_bytes[byte_index]
        if not data_good:
            break
        byte_index += 1
    fh.close()
    os.remove(filepath)
    return data_good