@@ -790,14 +790,6 @@ def test_touch_default_timeout(self, cache: ValkeyCache):
790790 time .sleep (2 )
791791 assert cache .get ("test_key" ) == "foo"
792792
793- def test_clear (self , cache : ValkeyCache ):
794- cache .set ("foo" , "bar" )
795- value_from_cache = cache .get ("foo" )
796- assert value_from_cache == "bar"
797- cache .clear ()
798- value_from_cache_after_clear = cache .get ("foo" )
799- assert value_from_cache_after_clear is None
800-
801793 def test_hset (self , cache : ValkeyCache ):
802794 if isinstance (cache .client , ShardClient ):
803795 pytest .skip ("ShardClient doesn't support get_client" )
@@ -1082,3 +1074,19 @@ def test_sunionstore(self, cache: ValkeyCache):
10821074 cache .sadd ("foo2" , "bar2" , "bar3" )
10831075 assert cache .sunionstore ("foo3" , "foo1" , "foo2" ) == 3
10841076 assert cache .smembers ("foo3" ) == {"bar1" , "bar2" , "bar3" }
1077+
1078+ def test_clear (self , cache : ValkeyCache ):
1079+ cache .set ("foo" , "bar" )
1080+ value_from_cache = cache .get ("foo" )
1081+ assert value_from_cache == "bar"
1082+ cache .clear ()
1083+ value_from_cache_after_clear = cache .get ("foo" )
1084+ assert value_from_cache_after_clear is None
1085+
1086+ def test_clear_true (self , cache : ValkeyCache ):
1087+ if isinstance (cache .client , ShardClient ):
1088+ pytest .skip ("ShardClient doesn't return on clear" )
1089+ cache .set ("foo" , "bar" )
1090+ assert cache .get ("foo" ) == "bar"
1091+ assert cache .clear () is True
1092+ assert cache .get ("foo" ) is None
0 commit comments