<s> from io import BytesIO <EOL> import pytest <EOL> from dask . bytes . compression import compress , decompress , files <EOL> def test_compression ( ) : <EOL> assert set ( compress ) == set ( decompress ) <EOL> a = b'<STR_LIT>' <EOL> for k in compress : <EOL> comp = compress [ k ] <EOL> decomp = decompress [ k ] <EOL> b = comp ( a ) <EOL> c = decomp ( b ) <EOL> assert a == c <EOL> if k is not None : <EOL> assert a != b <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , files . items ( ) ) <EOL> def test_files ( fmt , File ) : <EOL> if fmt is None : <EOL> return <EOL> data = b'<STR_LIT>' * <NUM_LIT:1000> <EOL> out = BytesIO ( ) <EOL> f = File ( out , mode = '<STR_LIT:wb>' ) <EOL> f . write ( data ) <EOL> f . close ( ) <EOL> out . seek ( <NUM_LIT:0> ) <EOL> compressed = out . read ( ) <EOL> assert len ( data ) > len ( compressed ) <EOL> b = BytesIO ( compressed ) <EOL> g = File ( b , mode = '<STR_LIT:rb>' ) <EOL> data2 = g . read ( ) <EOL> g . close ( ) <EOL> assert data == data2 </s>
