@@ -151,7 +151,7 @@ def test_guess_decode(self):
151151 self .assertIsNotNone (codext .stopfunc ._validate ("flag" ))
152152 _l = lambda d : list (d .items ())[0 ][1 ] if len (d ) > 0 else None
153153 codext .add ("test_codec" , lambda x , e = "strict" : (x + "=" , len (x )), lambda x , e = "strict" : (x [:- 1 ], len (x )- 1 ),
154- "test" , padding_char = "=" , no_error = True , bonus_func = lambda * a : True , penalty = - .5 )
154+ "^ test(?:_codec)?$ " , padding_char = "=" , no_error = True , bonus_func = lambda * a : True , penalty = - .5 )
155155 self .assertIn ("test-codec" , codext .list_encodings ("test" ))
156156 self .assertEqual (codext .decode ("TEST=" , "test" ), "TEST" )
157157 self .assertEqual (list (codext .guess ("TEST=" , codext .stopfunc .text , include = "test" , max_depth = 2 ,
@@ -203,13 +203,15 @@ def test_guess_decode(self):
203203 self .assertRaises (ValueError , codext .stopfunc ._reload_lang , "DOES_NOT_EXIST" )
204204
205205 def test_rank_input (self ):
206+ codext .remove ("test_codec" )
207+ self .assertRaises (LookupError , codext .encode , "TEST" , "test" )
206208 codext .add ("test_codec" , lambda x , e = "strict" : (x + "=" , len (x )), lambda x , e = "strict" : (x [:- 1 ], len (x )- 1 ),
207- "test" , padding_char = "=" , no_error = True , bonus_func = lambda * a : True , penalty = - .5 )
209+ "^ test(?:_codec)?$ " , padding_char = "=" , no_error = True , penalty = 1. )
208210 STR = "This is a test string !"
209211 ENC = codext .encode (STR , "base64" )
210212 self .assertTrue (len (codext .rank (ENC )) > 20 )
211213 self .assertEqual (len (codext .rank (ENC , limit = 20 )), 20 )
212- self .assertEqual (codext .rank (ENC , exclude = ["rot" ])[0 ][1 ], "base64" )
214+ self .assertIn (codext .rank (ENC , exclude = ["rot" ])[0 ][1 ], [ "base64" , "base64-url" ] )
213215 self .assertEqual (codext .rank (ENC , include = "base" )[0 ][0 ][1 ], STR )
214216 self .assertEqual (codext .rank (ENC , include = ["base" ])[0 ][0 ][1 ], STR )
215217 self .assertIsNotNone (codext .rank (ENC , include = ["base" ], exclude = ["does_not_exist" ])[0 ][0 ][1 ], STR )
0 commit comments