<s> import unittest <EOL> from os . path import join <EOL> from scrapy . utils . gz import gunzip <EOL> from tests import tests_datadir <EOL> SAMPLEDIR = join ( tests_datadir , '<STR_LIT>' ) <EOL> class GunzipTest ( unittest . TestCase ) : <EOL> def test_gunzip_basic ( self ) : <EOL> with open ( join ( SAMPLEDIR , '<STR_LIT>' ) , '<STR_LIT:rb>' ) as f : <EOL> text = gunzip ( f . read ( ) ) <EOL> self . assertEqual ( len ( text ) , <NUM_LIT> ) <EOL> def test_gunzip_truncated ( self ) : <EOL> with open ( join ( SAMPLEDIR , '<STR_LIT>' ) , '<STR_LIT:rb>' ) as f : <EOL> text = gunzip ( f . read ( ) ) <EOL> assert text . endswith ( b'<STR_LIT>' ) <EOL> def test_gunzip_no_gzip_file_raises ( self ) : <EOL> with open ( join ( SAMPLEDIR , '<STR_LIT>' ) , '<STR_LIT:rb>' ) as f : <EOL> self . assertRaises ( IOError , gunzip , f . read ( ) ) <EOL> def test_gunzip_truncated_short ( self ) : <EOL> with open ( join ( SAMPLEDIR , '<STR_LIT>' ) , '<STR_LIT:rb>' ) as f : <EOL> text = gunzip ( f . read ( ) ) <EOL> assert text . endswith ( b'<STR_LIT>' ) </s>
