Ejemplo n.º 1
0
def test_read_gzip_header_filename_with_bad_compression_method(homedir):
    # 9 is a bad method
    header = struct.pack("<BBBBIxxHBBcccc", 31, 139, 9, 12, 0, 2, 1, 1, b"a", b"b", b"c", b"\0")
    with tempfile.NamedTemporaryFile() as tf:
        tf.write(header)
        tf.seek(0)
        with pytest.raises(OSError, match=r"Unknown compression method"):
            read_gzip_header_filename(tf.name)
Ejemplo n.º 2
0
def test_read_gzip_header_filename(homedir):
    header = struct.pack('<BBBBIxxHBBcccc', 31, 139, 8, 12, 0, 2, 1, 1, b"a",
                         b"b", b"c", b"\0")
    with tempfile.NamedTemporaryFile() as tf:
        tf.write(header)
        tf.seek(0)
        assert 'abc' == read_gzip_header_filename(tf.name)
Ejemplo n.º 3
0
def test_read_gzip_header_filename_with_bad_file(homedir):
    with tempfile.NamedTemporaryFile() as tf:
        tf.write(b'test')
        tf.seek(0)
        with pytest.raises(OSError, match=r"Not a gzipped file"):
            read_gzip_header_filename(tf.name)