<s> """<STR_LIT>""" <EOL> import random <EOL> import unicodedata <EOL> from fauxfactory import ( <EOL> gen_alpha , <EOL> gen_alphanumeric , <EOL> gen_cjk , <EOL> gen_cyrillic , <EOL> gen_html , <EOL> gen_latin1 , <EOL> gen_numeric_string , <EOL> gen_string , <EOL> gen_utf8 , <EOL> _unicode_letters_generator , <EOL> ) <EOL> from sys import version_info <EOL> if version_info [ <NUM_LIT:0> : <NUM_LIT:2> ] == ( <NUM_LIT:2> , <NUM_LIT:6> ) : <EOL> import unittest2 as unittest <EOL> else : <EOL> import unittest <EOL> class TestStrings ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_gen_alpha_1 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_alpha ( ) <EOL> self . assertTrue ( <EOL> len ( result ) > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def test_gen_alpha_2 ( self ) : <EOL> """<STR_LIT>""" <EOL> for length in range ( <NUM_LIT:2> , <NUM_LIT:12> , <NUM_LIT:2> ) : <EOL> result = gen_alpha ( length ) <EOL> self . assertEqual ( <EOL> len ( result ) , <EOL> length , <EOL> "<STR_LIT>" ) <EOL> def test_gen_alpha_3_0 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alpha ( length = <NUM_LIT:0> ) <EOL> def test_gen_alpha_3_1 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alphanumeric ( length = <NUM_LIT:0> ) <EOL> def test_gen_alpha_3_2 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cjk ( length = <NUM_LIT:0> ) <EOL> def test_gen_alpha_3_3 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_latin1 ( length = <NUM_LIT:0> ) <EOL> def test_gen_alpha_3_4 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_numeric_string ( length = <NUM_LIT:0> ) <EOL> def test_gen_alpha_4 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alpha ( length = - <NUM_LIT:1> ) <EOL> def test_gen_alpha_5 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alpha ( length = None ) <EOL> def test_gen_alpha_6 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alpha ( length = '<STR_LIT>' ) <EOL> def test_gen_alpha_7 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alpha ( length = '<STR_LIT:U+0020>' ) <EOL> def test_gen_alpha_8 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alpha ( length = '<STR_LIT:a>' ) <EOL> def test_gen_alpha_9 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_string ( '<STR_LIT>' , <NUM_LIT:15> ) <EOL> self . assertTrue ( <EOL> len ( result ) > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def test_gen_alphanumeric_1 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_alphanumeric ( ) <EOL> self . assertTrue ( <EOL> len ( result ) > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def test_gen_alphanumeric_2 ( self ) : <EOL> """<STR_LIT>""" <EOL> for length in range ( <NUM_LIT:2> , <NUM_LIT:12> , <NUM_LIT:2> ) : <EOL> result = gen_alphanumeric ( length ) <EOL> self . assertEqual ( <EOL> len ( result ) , <EOL> length , <EOL> "<STR_LIT>" ) <EOL> def test_gen_alphanumeric_3 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alphanumeric ( length = <NUM_LIT:0> ) <EOL> def test_gen_alphanumeric_4 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alphanumeric ( length = - <NUM_LIT:1> ) <EOL> def test_gen_alphanumeric_5 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alphanumeric ( length = None ) <EOL> def test_gen_alphanumeric_6 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alphanumeric ( length = '<STR_LIT>' ) <EOL> def test_gen_alphanumeric_7 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alphanumeric ( length = '<STR_LIT:U+0020>' ) <EOL> def test_gen_alphanumeric_8 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_alphanumeric ( length = '<STR_LIT:a>' ) <EOL> def test_gen_cjk_1 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_cjk ( ) <EOL> self . assertTrue ( <EOL> len ( result ) > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def test_gen_cjk_2 ( self ) : <EOL> """<STR_LIT>""" <EOL> for length in range ( <NUM_LIT:2> , <NUM_LIT:12> , <NUM_LIT:2> ) : <EOL> result = gen_cjk ( length ) <EOL> self . assertEqual ( <EOL> len ( result ) , <EOL> length , <EOL> "<STR_LIT>" ) <EOL> def test_gen_cjk_3 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cjk ( length = <NUM_LIT:0> ) <EOL> def test_gen_cjk_4 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cjk ( length = - <NUM_LIT:1> ) <EOL> def test_gen_cjk_5 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cjk ( length = None ) <EOL> def test_gen_cjk_6 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cjk ( length = '<STR_LIT>' ) <EOL> def test_gen_cjk_7 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cjk ( length = '<STR_LIT:U+0020>' ) <EOL> def test_gen_cjk_8 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cjk ( length = '<STR_LIT:a>' ) <EOL> def test_gen_cjk_9 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_string ( '<STR_LIT>' , <NUM_LIT:15> ) <EOL> self . assertTrue ( <EOL> len ( result ) > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def test_gen_cyrillic_1 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_cyrillic ( ) <EOL> self . assertTrue ( <EOL> len ( result ) > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def test_gen_cyrillic_2 ( self ) : <EOL> """<STR_LIT>""" <EOL> for length in range ( <NUM_LIT:2> , <NUM_LIT:12> , <NUM_LIT:2> ) : <EOL> result = gen_cyrillic ( length ) <EOL> self . assertEqual ( <EOL> len ( result ) , <EOL> length , <EOL> "<STR_LIT>" ) <EOL> def test_gen_cyrillic_3 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cyrillic ( length = <NUM_LIT:0> ) <EOL> def test_gen_cyrillic_4 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cyrillic ( length = - <NUM_LIT:1> ) <EOL> def test_gen_cyrillic_5 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cyrillic ( length = None ) <EOL> def test_gen_cyrillic_6 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cyrillic ( length = '<STR_LIT>' ) <EOL> def test_gen_cyrillic_7 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cyrillic ( length = '<STR_LIT:U+0020>' ) <EOL> def test_gen_cyrillic_8 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_cyrillic ( length = '<STR_LIT:a>' ) <EOL> def test_gen_cyrillic_9 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_string ( '<STR_LIT>' , <NUM_LIT:15> ) <EOL> self . assertTrue ( <EOL> len ( result ) > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def test_gen_utf8_1 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_string ( '<STR_LIT:utf8>' , <NUM_LIT:5> ) <EOL> if version_info [ <NUM_LIT:0> ] == <NUM_LIT:2> : <EOL> self . assertTrue ( isinstance ( result , unicode ) ) <EOL> else : <EOL> self . assertTrue ( isinstance ( result , str ) ) <EOL> def test_gen_utf8_2 ( self ) : <EOL> """<STR_LIT>""" <EOL> length = random . randint ( <NUM_LIT:1> , <NUM_LIT:100> ) <EOL> self . assertEqual ( <EOL> len ( gen_string ( '<STR_LIT:utf8>' , length ) ) , <EOL> length <EOL> ) <EOL> def test_gen_utf8_3 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_string ( '<STR_LIT:utf8>' , '<STR_LIT:foo>' ) <EOL> def test_gen_latin1_1 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_latin1 ( ) <EOL> self . assertTrue ( <EOL> len ( result ) > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def test_gen_latin1_2 ( self ) : <EOL> """<STR_LIT>""" <EOL> for length in range ( <NUM_LIT:2> , <NUM_LIT:12> , <NUM_LIT:2> ) : <EOL> result = gen_latin1 ( length ) <EOL> self . assertEqual ( <EOL> len ( result ) , <EOL> length , <EOL> "<STR_LIT>" ) <EOL> def test_gen_latin1_3 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_latin1 ( length = <NUM_LIT:0> ) <EOL> def test_gen_latin1_4 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_latin1 ( length = - <NUM_LIT:1> ) <EOL> def test_gen_latin1_5 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_latin1 ( length = None ) <EOL> def test_gen_latin1_6 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_latin1 ( length = '<STR_LIT>' ) <EOL> def test_gen_latin1_7 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_latin1 ( length = '<STR_LIT:U+0020>' ) <EOL> def test_gen_latin1_8 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_latin1 ( length = '<STR_LIT:a>' ) <EOL> def test_gen_latin1_9 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_string ( '<STR_LIT>' , <NUM_LIT:15> ) <EOL> self . assertTrue ( <EOL> len ( result ) > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def test_gen_numeric_string_1 ( self ) : <EOL> """<STR_LIT>""" <EOL> result = gen_numeric_string ( ) <EOL> self . assertTrue ( <EOL> len ( result ) > <NUM_LIT:0> , "<STR_LIT>" ) <EOL> def test_gen_numeric_string_2 ( self ) : <EOL> """<STR_LIT>""" <EOL> for length in range ( <NUM_LIT:2> , <NUM_LIT:12> , <NUM_LIT:2> ) : <EOL> result = gen_numeric_string ( length ) <EOL> self . assertEqual ( <EOL> len ( result ) , <EOL> length , <EOL> "<STR_LIT>" ) <EOL> def test_gen_numeric_string_3 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_numeric_string ( length = <NUM_LIT:0> ) <EOL> def test_gen_numeric_string_4 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_numeric_string ( length = - <NUM_LIT:1> ) <EOL> def test_gen_numeric_string_5 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_numeric_string ( length = None ) <EOL> def test_gen_numeric_string_6 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_numeric_string ( length = '<STR_LIT>' ) <EOL> def test_gen_numeric_string_7 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_numeric_string ( length = '<STR_LIT:U+0020>' ) <EOL> def test_gen_numeric_string_8 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_numeric_string ( length = '<STR_LIT:a>' ) <EOL> def test_gen_string ( self ) : <EOL> """<STR_LIT>""" <EOL> alphanumeric_string = gen_string ( '<STR_LIT>' , <NUM_LIT:15> ) <EOL> self . assertEqual ( <NUM_LIT:15> , len ( alphanumeric_string ) , <EOL> "<STR_LIT>" ) <EOL> def test_gen_string2 ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( Exception ) : <EOL> gen_string ( '<STR_LIT>' , <NUM_LIT:15> ) <EOL> def test_gen_string3 ( self ) : <EOL> """<STR_LIT>""" <EOL> numeric_string = gen_string ( '<STR_LIT>' , <NUM_LIT:20> ) <EOL> self . assertEqual ( <NUM_LIT:20> , len ( numeric_string ) , <EOL> "<STR_LIT>" ) <EOL> def test_gen_string4 ( self ) : <EOL> """<STR_LIT>""" <EOL> html_string = gen_string ( '<STR_LIT:html>' , <NUM_LIT:10> ) <EOL> self . assertTrue ( len ( html_string ) > <NUM_LIT:10> , <EOL> "<STR_LIT>" ) <EOL> def test_gen_string5 ( self ) : <EOL> """<STR_LIT>""" <EOL> invalid_string_type = gen_string ( '<STR_LIT>' , <NUM_LIT:10> ) <EOL> with self . assertRaises ( ValueError ) : <EOL> gen_string ( invalid_string_type , <NUM_LIT:10> ) <EOL> def test_gen_string6 ( self ) : <EOL> """<STR_LIT>""" <EOL> alphanumeric_string = gen_string ( '<STR_LIT>' ) <EOL> control_string = gen_alphanumeric ( ) <EOL> self . assertEqual ( len ( control_string ) , len ( alphanumeric_string ) , ) <EOL> class UnicodeLettersGenerator ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_chars_in_letters_category ( self ) : <EOL> """<STR_LIT>""" <EOL> for char in _unicode_letters_generator ( ) : <EOL> self . assertIn ( <EOL> unicodedata . category ( char ) , ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> ) </s>
