def test_decompression_of_official_corrupt_fixtures(fixture_name): fixture_data = load_fixture(fixture_name) with pytest.raises(BaseSnappyError): decompress(fixture_data) # now ensure that the canonical implementation errors too with pytest.raises(UncompressError): libsnappy_decompress(fixture_data)
def test_decompress_error_parity(value): try: py_result = decompress(value) except PY_SNAPPY_ERRORS: py_snappy_error = True else: py_snappy_error = False try: lib_result = libsnappy_decompress(value) except LIB_SNAPPY_ERRORS: lib_snappy_error = True else: lib_snappy_error = False if py_snappy_error and lib_snappy_error: pass elif not py_snappy_error and not lib_snappy_error: assert lib_result == py_result else: raise AssertionError( f"behavioral mismatch: py_snappy: {pass_fail(py_snappy_error)} lib-snappy: {pass_fail(lib_snappy_error)}" # noqa: E501 )
def test_decompress_empty_string(): with pytest.raises(CorruptError): decompress(b"")
def test_decompress_libsnappy_compressed_test_fixture(fixture_name): fixture_data = load_fixture(fixture_name) intermediate = libsnappy_compress(fixture_data) actual = decompress(intermediate) assert fixture_data == actual
def test_compression_round_trip_of_official_test_fixtures(fixture_name): fixture_data = load_fixture(fixture_name) intermediate = compress(fixture_data) actual = decompress(intermediate) assert fixture_data == actual
def test_local_decompress_libsnappy_compressed(value): intermediate = libsnappy_compress(value) result = decompress(intermediate) assert value == result
def test_round_trip(value): intermediate = compress(value) result = decompress(intermediate) assert value == result