@@ -123,8 +123,10 @@ def test_keys_are_truncated_beyond_250_chars(self):
123123 except Exception :
124124 self .fail ('Keys are not being correctly truncated.' )
125125
126+ from hashlib import sha256
126127
127128class KeyCreationTestCase (TestCase ):
129+
128130 def setUp (self ):
129131 self .apple = Fruit ('Apple' )
130132 self .cherry = Fruit ('Cherry' )
@@ -141,7 +143,23 @@ def test_args_kwargs_properly_convert_to_string(self):
141143
142144 def test_dict_args_properly_convert_to_string (self ):
143145 same_cherry = self .apple .take_then_give_back ({1 : self .cherry })
144- self .assertTrue ('tests.Fruit.take_then_give_back:42;mynameisapple,,,1,mynameischerry;' in cache )
146+ hashed_key = sha256 (str (1 ).encode ('utf-8' )).hexdigest ()
147+ self .assertTrue ('tests.Fruit.take_then_give_back:42;mynameisapple,,,{0},mynameischerry;' .format (hashed_key ) in cache )
148+
149+ def test_dict_args_keep_the_same_order_when_convert_to_string (self ):
150+ dict_arg = {1 : self .cherry , 'string' : 'ay carambe' }
151+ same_multi_dict = self .apple .take_then_give_back (dict_arg )
152+
153+ self .assertTrue ('tests.Fruit.take_then_give_back:42;mynameisapple,,,'
154+ '473287f8298dba7163a897908958f7c0eae733e25d2e027992ea2edc9bed2fa8,aycarambe,,'
155+ '6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b,mynameischerry;' in cache )
156+
157+ def test_set_args_properly_maintain_order_and_convert_to_string (self ):
158+ same_set = self .apple .take_then_give_back ({1 ,'vegetable' , self .cherry })
159+ self .assertTrue ('tests.Fruit.take_then_give_back:42;mynameisapple,,'
160+ '4715b734085d8d9c9981d91c6d5cff398c75caf44074851baa94f2de24fba4d7,'
161+ '6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b,'
162+ 'f8201a5264b6b89b4d92c5bc46aa2e5c3e9610e8fc9ef200df1a39c7f10e7af6;' in cache )
145163
146164 def test_list_args_properly_convert_to_string (self ):
147165 same_cherry = self .apple .take_then_give_back ([self .cherry ])
0 commit comments