<s> """<STR_LIT>""" <EOL> import sys <EOL> import os <EOL> import unittest <EOL> import tempfile <EOL> import threading <EOL> import logging <EOL> def fix_sys_path ( ) : <EOL> """<STR_LIT>""" <EOL> def add_path_first ( path ) : <EOL> sys . path = [ path ] + [ p for p in sys . path if ( <EOL> not p == path and not p == ( path + '<STR_LIT:/>' ) ) ] <EOL> path = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> if not os . path . isfile ( os . path . join ( path , '<STR_LIT>' ) ) : <EOL> i = <NUM_LIT:0> <EOL> while i < <NUM_LIT:10> : <EOL> i += <NUM_LIT:1> <EOL> if os . path . exists ( os . path . join ( path , '<STR_LIT>' ) ) : <EOL> break <EOL> path = os . path . abspath ( os . path . join ( path , '<STR_LIT:..>' ) ) <EOL> paths = [ path , <EOL> os . path . abspath ( os . path . join ( path , '<STR_LIT>' ) ) , <EOL> os . path . abspath ( os . path . join ( path , '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ] <EOL> [ add_path_first ( path ) for path in paths ] <EOL> fix_sys_path ( ) <EOL> import languages <EOL> from storage import Storage <EOL> try : <EOL> import multiprocessing <EOL> def read_write ( args ) : <EOL> ( filename , iterations ) = args <EOL> for i in range ( <NUM_LIT:0> , iterations ) : <EOL> content = languages . read_dict ( filename ) <EOL> if not len ( content ) : <EOL> return False <EOL> languages . write_dict ( filename , content ) <EOL> return True <EOL> class TestLanguagesParallel ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . filename = tempfile . mktemp ( ) <EOL> contents = dict ( ) <EOL> for i in range ( <NUM_LIT:1000> ) : <EOL> contents [ "<STR_LIT>" % i ] = "<STR_LIT>" % i <EOL> languages . write_dict ( self . filename , contents ) <EOL> languages . read_dict ( self . filename ) <EOL> def tearDown ( self ) : <EOL> try : <EOL> os . remove ( self . filename ) <EOL> except : <EOL> pass <EOL> def test_reads_and_writes ( self ) : <EOL> readwriters = <NUM_LIT:10> <EOL> pool = multiprocessing . Pool ( processes = readwriters ) <EOL> results = pool . map ( read_write , [ [ self . filename , <NUM_LIT:10> ] ] * readwriters ) <EOL> for result in results : <EOL> self . assertTrue ( result ) <EOL> class TestTranslations ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> if os . path . isdir ( '<STR_LIT>' ) : <EOL> self . langpath = '<STR_LIT>' <EOL> else : <EOL> self . langpath = os . path . realpath ( <EOL> '<STR_LIT>' ) <EOL> self . http_accept_language = '<STR_LIT>' <EOL> def tearDown ( self ) : <EOL> pass <EOL> def test_plain ( self ) : <EOL> T = languages . translator ( self . langpath , self . http_accept_language ) <EOL> self . assertEqual ( str ( T ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( str ( T ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( str ( T ( '<STR_LIT>' , <NUM_LIT:1> ) ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( str ( T ( '<STR_LIT>' , <NUM_LIT:2> ) ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( str ( T ( '<STR_LIT>' , <NUM_LIT:1> ) ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( str ( T ( '<STR_LIT>' , <NUM_LIT:2> ) ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( str ( T ( '<STR_LIT>' , <NUM_LIT:1> ) ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( str ( T ( '<STR_LIT>' , <NUM_LIT:2> ) ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( str ( T . M ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) <EOL> T . force ( '<STR_LIT>' ) <EOL> self . assertEqual ( str ( T ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) <EOL> except ImportError : <EOL> logging . warning ( "<STR_LIT>" ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
