<s> from datetime import datetime <EOL> import time <EOL> import unittest <EOL> from babel import __version__ as VERSION <EOL> from babel . core import Locale , UnknownLocaleError <EOL> from babel . dates import format_datetime <EOL> from babel . messages import checkers <EOL> from babel . messages . plurals import PLURALS <EOL> from babel . messages . pofile import read_po <EOL> from babel . util import LOCALTZ <EOL> from babel . _compat import BytesIO <EOL> class CheckersTestCase ( unittest . TestCase ) : <EOL> def test_1_num_plurals_checkers ( self ) : <EOL> for _locale in [ p for p in PLURALS if PLURALS [ p ] [ <NUM_LIT:0> ] == <NUM_LIT:1> ] : <EOL> try : <EOL> locale = Locale . parse ( _locale ) <EOL> except UnknownLocaleError : <EOL> continue <EOL> po_file = ( u"""<STR_LIT>""" % dict ( locale = _locale , <EOL> english_name = locale . english_name , <EOL> version = VERSION , <EOL> year = time . strftime ( '<STR_LIT>' ) , <EOL> date = format_datetime ( datetime . now ( LOCALTZ ) , <EOL> '<STR_LIT>' , <EOL> tzinfo = LOCALTZ , locale = _locale ) , <EOL> num_plurals = PLURALS [ _locale ] [ <NUM_LIT:0> ] , <EOL> plural_expr = PLURALS [ _locale ] [ <NUM_LIT:0> ] ) ) . encode ( '<STR_LIT:utf-8>' ) <EOL> catalog = read_po ( BytesIO ( po_file ) , _locale ) <EOL> message = catalog [ '<STR_LIT>' ] <EOL> checkers . num_plurals ( catalog , message ) <EOL> def test_2_num_plurals_checkers ( self ) : <EOL> for _locale in [ p for p in PLURALS if PLURALS [ p ] [ <NUM_LIT:0> ] == <NUM_LIT:2> ] : <EOL> if _locale in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> _locale = '<STR_LIT>' <EOL> num_plurals = PLURALS [ _locale . split ( '<STR_LIT:_>' ) [ <NUM_LIT:0> ] ] [ <NUM_LIT:0> ] <EOL> plural_expr = PLURALS [ _locale . split ( '<STR_LIT:_>' ) [ <NUM_LIT:0> ] ] [ <NUM_LIT:1> ] <EOL> else : <EOL> num_plurals = PLURALS [ _locale ] [ <NUM_LIT:0> ] <EOL> plural_expr = PLURALS [ _locale ] [ <NUM_LIT:1> ] <EOL> try : <EOL> locale = Locale ( _locale ) <EOL> date = format_datetime ( datetime . now ( LOCALTZ ) , <EOL> '<STR_LIT>' , <EOL> tzinfo = LOCALTZ , locale = _locale ) <EOL> except UnknownLocaleError : <EOL> continue <EOL> po_file = ( u"""<STR_LIT>""" % dict ( locale = _locale , <EOL> english_name = locale . english_name , <EOL> version = VERSION , <EOL> year = time . strftime ( '<STR_LIT>' ) , <EOL> date = date , <EOL> num_plurals = num_plurals , <EOL> plural_expr = plural_expr ) ) . encode ( '<STR_LIT:utf-8>' ) <EOL> catalog = read_po ( BytesIO ( po_file ) , _locale ) <EOL> message = catalog [ '<STR_LIT>' ] <EOL> checkers . num_plurals ( catalog , message ) <EOL> def test_3_num_plurals_checkers ( self ) : <EOL> for _locale in [ p for p in PLURALS if PLURALS [ p ] [ <NUM_LIT:0> ] == <NUM_LIT:3> ] : <EOL> po_file = ( r"""<STR_LIT>""" % dict ( locale = _locale , <EOL> english_name = Locale . parse ( _locale ) . english_name , <EOL> version = VERSION , <EOL> year = time . strftime ( '<STR_LIT>' ) , <EOL> date = format_datetime ( datetime . now ( LOCALTZ ) , <EOL> '<STR_LIT>' , <EOL> tzinfo = LOCALTZ , locale = _locale ) , <EOL> num_plurals = PLURALS [ _locale ] [ <NUM_LIT:0> ] , <EOL> plural_expr = PLURALS [ _locale ] [ <NUM_LIT:0> ] ) ) . encode ( '<STR_LIT:utf-8>' ) <EOL> catalog = read_po ( BytesIO ( po_file ) , _locale ) <EOL> message = catalog [ '<STR_LIT>' ] <EOL> checkers . num_plurals ( catalog , message ) <EOL> def test_4_num_plurals_checkers ( self ) : <EOL> for _locale in [ p for p in PLURALS if PLURALS [ p ] [ <NUM_LIT:0> ] == <NUM_LIT:4> ] : <EOL> po_file = ( r"""<STR_LIT>""" % dict ( locale = _locale , <EOL> english_name = Locale . parse ( _locale ) . english_name , <EOL> version = VERSION , <EOL> year = time . strftime ( '<STR_LIT>' ) , <EOL> date = format_datetime ( datetime . now ( LOCALTZ ) , <EOL> '<STR_LIT>' , <EOL> tzinfo = LOCALTZ , locale = _locale ) , <EOL> num_plurals = PLURALS [ _locale ] [ <NUM_LIT:0> ] , <EOL> plural_expr = PLURALS [ _locale ] [ <NUM_LIT:0> ] ) ) . encode ( '<STR_LIT:utf-8>' ) <EOL> catalog = read_po ( BytesIO ( po_file ) , _locale ) <EOL> message = catalog [ '<STR_LIT>' ] <EOL> checkers . num_plurals ( catalog , message ) <EOL> def test_5_num_plurals_checkers ( self ) : <EOL> for _locale in [ p for p in PLURALS if PLURALS [ p ] [ <NUM_LIT:0> ] == <NUM_LIT:5> ] : <EOL> po_file = ( r"""<STR_LIT>""" % dict ( locale = _locale , <EOL> english_name = Locale . parse ( _locale ) . english_name , <EOL> version = VERSION , <EOL> year = time . strftime ( '<STR_LIT>' ) , <EOL> date = format_datetime ( datetime . now ( LOCALTZ ) , <EOL> '<STR_LIT>' , <EOL> tzinfo = LOCALTZ , locale = _locale ) , <EOL> num_plurals = PLURALS [ _locale ] [ <NUM_LIT:0> ] , <EOL> plural_expr = PLURALS [ _locale ] [ <NUM_LIT:0> ] ) ) . encode ( '<STR_LIT:utf-8>' ) <EOL> catalog = read_po ( BytesIO ( po_file ) , _locale ) <EOL> message = catalog [ '<STR_LIT>' ] <EOL> checkers . num_plurals ( catalog , message ) <EOL> def test_6_num_plurals_checkers ( self ) : <EOL> for _locale in [ p for p in PLURALS if PLURALS [ p ] [ <NUM_LIT:0> ] == <NUM_LIT:6> ] : <EOL> po_file = ( r"""<STR_LIT>""" % dict ( locale = _locale , <EOL> english_name = Locale . parse ( _locale ) . english_name , <EOL> version = VERSION , <EOL> year = time . strftime ( '<STR_LIT>' ) , <EOL> date = format_datetime ( datetime . now ( LOCALTZ ) , <EOL> '<STR_LIT>' , <EOL> tzinfo = LOCALTZ , locale = _locale ) , <EOL> num_plurals = PLURALS [ _locale ] [ <NUM_LIT:0> ] , <EOL> plural_expr = PLURALS [ _locale ] [ <NUM_LIT:0> ] ) ) . encode ( '<STR_LIT:utf-8>' ) <EOL> catalog = read_po ( BytesIO ( po_file ) , _locale ) <EOL> message = catalog [ '<STR_LIT>' ] <EOL> checkers . num_plurals ( catalog , message ) </s>
