<s> import re <EOL> from collections import namedtuple <EOL> from boltons . formatutils import ( get_format_args , <EOL> split_format_str , <EOL> tokenize_format_str , <EOL> infer_positional_format_args ) <EOL> PFAT = namedtuple ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> _PFATS = [ PFAT ( '<STR_LIT>' , ( '<STR_LIT>' , '<STR_LIT:hello>' , '<STR_LIT>' ) , "<STR_LIT>" ) , <EOL> PFAT ( '<STR_LIT>' , ( <NUM_LIT:1> , <NUM_LIT:2> ) , "<STR_LIT>" ) , <EOL> PFAT ( '<STR_LIT>' , ( '<STR_LIT:str>' , '<STR_LIT>' ) , "<STR_LIT>" ) , <EOL> PFAT ( '<STR_LIT>' , ( { '<STR_LIT>' : '<STR_LIT>' } , re ) , "<STR_LIT>" ) , <EOL> PFAT ( '<STR_LIT>' , ( '<STR_LIT>' , '<STR_LIT>' ) , "<STR_LIT>" ) ] <EOL> def test_pos_infer ( ) : <EOL> for i , ( tmpl , args , res ) in enumerate ( _PFATS ) : <EOL> converted = infer_positional_format_args ( tmpl ) <EOL> assert converted . format ( * args ) == res <EOL> _TEST_TMPLS = [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> try : <EOL> from collections import OrderedDict <EOL> except ImportError : <EOL> pass <EOL> else : <EOL> _TEST_TMPLS . append ( "<STR_LIT>" ) <EOL> del OrderedDict <EOL> def test_get_fstr_args ( ) : <EOL> results = [ ] <EOL> for t in _TEST_TMPLS : <EOL> inferred_t = infer_positional_format_args ( t ) <EOL> res = get_format_args ( inferred_t ) <EOL> results . append ( res ) <EOL> return results <EOL> def test_split_fstr ( ) : <EOL> results = [ ] <EOL> for t in _TEST_TMPLS : <EOL> res = split_format_str ( t ) <EOL> results . append ( res ) <EOL> return results <EOL> def test_tokenize_format_str ( ) : <EOL> results = [ ] <EOL> for t in _TEST_TMPLS : <EOL> res = tokenize_format_str ( t ) <EOL> results . append ( res ) <EOL> return results </s>
