#NEWLINE# def testSeek( self ) : #NEWLINE# #INDENT# 'Test the seek functionality.' #NEWLINE# file_object = fake_file_io . FakeFile ( self . _resolver_context , self . _FILE_DATA2 ) #NEWLINE# file_object . open ( path_spec = self . _path_spec2 ) #NEWLINE# self . assertEqual ( file_object . get_size ( ) , 22 ) #NEWLINE# file_object . seek ( 10 ) #NEWLINE# self . assertEqual ( file_object . read ( 5 ) , b'other' ) #NEWLINE# self . assertEqual ( file_object . get_offset ( ) , 15 ) #NEWLINE# file_object . seek ( ( - 10 ) , os . SEEK_END ) #NEWLINE# self . assertEqual ( file_object . read ( 5 ) , b'her f' ) #NEWLINE# file_object . seek ( 2 , os . SEEK_CUR ) #NEWLINE# self . assertEqual ( file_object . read ( 2 ) , b'e.' ) #NEWLINE# file_object . seek ( 300 , os . SEEK_SET ) #NEWLINE# self . assertEqual ( file_object . get_offset ( ) , 300 ) #NEWLINE# self . assertEqual ( file_object . read ( 2 ) , b'' ) #NEWLINE# with self . assertRaises ( IOError ) : #NEWLINE# #INDENT# file_object . seek ( ( - 10 ) , os . SEEK_SET ) #NEWLINE# #UNINDENT# self . assertEqual ( file_object . get_offset ( ) , 300 ) #NEWLINE# with self . assertRaises ( IOError ) : #NEWLINE# #INDENT# file_object . seek ( 10 , 5 ) #NEWLINE# #UNINDENT# self . assertEqual ( file_object . get_offset ( ) , 300 ) #NEWLINE# file_object . close ( )