@@ -279,7 +279,7 @@ def test_dict_method_pop_default(self):
279
279
self .assertEqual (len (dic ), len (input_items ) - i )
280
280
self .assertEqual (len (redis_dic ), len (input_items ) - i )
281
281
282
- expected = "defualt item"
282
+ expected = "default item"
283
283
self .assertEqual (dic .pop ("item" , expected ), expected )
284
284
self .assertEqual (redis_dic .pop ("item" , expected ), expected )
285
285
@@ -696,18 +696,18 @@ def test_set_and_get_multiple(self):
696
696
self .assertEqual (self .r ['foobar1' ], 'barbar1' )
697
697
self .assertEqual (self .r ['foobar2' ], 'barbar2' )
698
698
699
- def test_get_nonexisting (self ):
699
+ def test_get_non_existing (self ):
700
700
"""Test that retrieving a non-existing key raises a KeyError."""
701
701
with self .assertRaises (KeyError ):
702
- _ = self .r ['nonexistingkey ' ]
702
+ _ = self .r ['non_existing_key ' ]
703
703
704
704
def test_delete (self ):
705
705
"""Test deleting a key."""
706
- self .r ['foobargone' ] = 'bars'
706
+ key = 'foobar_gone'
707
+ self .r [key ] = 'bar'
707
708
708
- del self .r ['foobargone' ]
709
-
710
- self .assertEqual (self .redisdb .get ('foobargone' ), None )
709
+ del self .r [key ]
710
+ self .assertEqual (self .redisdb .get (key ), None )
711
711
712
712
def test_contains_empty (self ):
713
713
"""Tests the __contains__ function with no keys set."""
@@ -729,17 +729,21 @@ def test_repr_empty(self):
729
729
730
730
def test_repr_nonempty (self ):
731
731
"""Tests the __repr__ function with keys set."""
732
- self .r ['foobars' ] = 'barrbars'
733
- expected_repr = str ({'foobars' : 'barrbars' })
734
- actual_repr = repr (self .r )
735
- self .assertEqual (actual_repr , expected_repr )
732
+ key = 'foobar'
733
+ val = 'bar'
734
+ self .r [key ] = val
735
+ expected = str ({key : val })
736
+ result = repr (self .r )
737
+ self .assertEqual (result , expected )
736
738
737
739
def test_str_nonempty (self ):
738
740
"""Tests the __repr__ function with keys set."""
739
- self .r ['foobars' ] = 'barrbars'
740
- expected_str = str ({'foobars' : 'barrbars' })
741
- actual_str = str (self .r )
742
- self .assertEqual (actual_str , expected_str )
741
+ key = 'foobar'
742
+ val = 'bar'
743
+ self .r [key ] = val
744
+ expected = str ({key : val })
745
+ result = str (self .r )
746
+ self .assertEqual (result , expected )
743
747
744
748
def test_len_empty (self ):
745
749
"""Tests the __repr__ function with no keys set."""
@@ -820,15 +824,15 @@ def test_chain_del_2(self):
820
824
_ = self .r .chain_get (['foo' , 'bar' ])
821
825
822
826
def test_expire_context (self ):
823
- """Test adding keys with an expire value by using the contextmanager."""
827
+ """Test adding keys with an ` expire` value by using the contextmanager."""
824
828
with self .r .expire_at (3600 ):
825
829
self .r ['foobar' ] = 'barbar'
826
830
827
831
actual_ttl = self .redisdb .ttl ('{}:foobar' .format (TEST_NAMESPACE_PREFIX ))
828
832
self .assertAlmostEqual (3600 , actual_ttl , delta = 2 )
829
833
830
834
def test_expire_context_timedelta (self ):
831
- """ Test adding keys with an expire value by using the contextmanager. With timedelta as argument. """
835
+ """ Test adding keys with an ` expire` value by using the contextmanager. With timedelta as argument. """
832
836
timedelta_one_hour = timedelta (hours = 1 )
833
837
timedelta_one_minute = timedelta (minutes = 1 )
834
838
hour_in_seconds = 60 * 60
@@ -845,15 +849,15 @@ def test_expire_context_timedelta(self):
845
849
self .assertAlmostEqual (minute_in_seconds , actual_ttl , delta = 2 )
846
850
847
851
def test_expire_keyword (self ):
848
- """Test adding keys with an expire value by using the expire config keyword."""
852
+ """Test adding keys with an ` expire` value by using the ` expire` config keyword."""
849
853
r = self .create_redis_dict (expire = 3600 )
850
854
851
855
r ['foobar' ] = 'barbar'
852
856
actual_ttl = self .redisdb .ttl ('{}:foobar' .format (TEST_NAMESPACE_PREFIX ))
853
857
self .assertAlmostEqual (3600 , actual_ttl , delta = 2 )
854
858
855
859
def test_expire_keyword_timedelta (self ):
856
- """ Test adding keys with an expire value by using the expire config keyword. With timedelta as argument."""
860
+ """ Test adding keys with an ` expire` value by using the ` expire` config keyword. With timedelta as argument."""
857
861
timedelta_one_hour = timedelta (hours = 1 )
858
862
timedelta_one_minute = timedelta (minutes = 1 )
859
863
hour_in_seconds = 60 * 60
@@ -1153,13 +1157,13 @@ def setUp(self):
1153
1157
self .clear_test_namespace ()
1154
1158
1155
1159
def test_unicode_key (self ):
1156
- # Test handling of unicode keys
1160
+ # Test handling of Unicode keys
1157
1161
unicode_key = '你好'
1158
1162
self .r [unicode_key ] = 'value'
1159
1163
self .assertEqual (self .r [unicode_key ], 'value' )
1160
1164
1161
1165
def test_unicode_value (self ):
1162
- # Test handling of unicode values
1166
+ # Test handling of Unicode values
1163
1167
unicode_value = '世界'
1164
1168
self .r ['key' ] = unicode_value
1165
1169
self .assertEqual (self .r ['key' ], unicode_value )
@@ -1486,7 +1490,7 @@ def test_preserve_expiration(self):
1486
1490
value = "bar"
1487
1491
redis_dict [key ] = value
1488
1492
1489
- # Ensure the TTL (time-to-live) of the "foo" key is approximately the global expire time.
1493
+ # Ensure the TTL (time-to-live) of the "foo" key is approximately the global ` expire` time.
1490
1494
actual_ttl = redis_dict .get_ttl (key )
1491
1495
self .assertAlmostEqual (3600 , actual_ttl , delta = 1 )
1492
1496
@@ -1502,7 +1506,7 @@ def test_preserve_expiration(self):
1502
1506
actual_ttl_foo = redis_dict .get_ttl (key )
1503
1507
self .assertAlmostEqual (3600 - time_sleeping , actual_ttl_foo , delta = 1 )
1504
1508
1505
- # Ensure the TTL of the "bar" key is also approximately the global expire time.
1509
+ # Ensure the TTL of the "bar" key is also approximately the global ` expire` time.
1506
1510
actual_ttl_bar = redis_dict .get_ttl (new_key )
1507
1511
1508
1512
self .assertAlmostEqual (3600 , actual_ttl_bar , delta = 1 )
@@ -1518,7 +1522,7 @@ def test_preserve_expiration_not_used(self):
1518
1522
value = "bar"
1519
1523
redis_dict [key ] = value
1520
1524
1521
- # Ensure the TTL (time-to-live) of the "foo" key is approximately the global expire time.
1525
+ # Ensure the TTL (time-to-live) of the "foo" key is approximately the global ` expire` time.
1522
1526
actual_ttl = redis_dict .get_ttl (key )
1523
1527
self .assertAlmostEqual (3600 , actual_ttl , delta = 1 )
1524
1528
@@ -1534,12 +1538,12 @@ def test_preserve_expiration_not_used(self):
1534
1538
actual_ttl_foo = redis_dict .get_ttl (key )
1535
1539
self .assertAlmostEqual (3600 , actual_ttl_foo , delta = 1 )
1536
1540
1537
- # Ensure the TTL of the "bar" key is also approximately the global expire time.
1541
+ # Ensure the TTL of the "bar" key is also approximately the global ` expire` time.
1538
1542
actual_ttl_bar = redis_dict .get_ttl (new_key )
1539
1543
1540
1544
self .assertAlmostEqual (3600 , actual_ttl_bar , delta = 1 )
1541
1545
1542
- # Ensure the difference between the TTLs of "foo" and "bar" is no more then 1 seconds .
1546
+ # Ensure the difference between the TTLs of "foo" and "bar" is no more than one second .
1543
1547
self .assertTrue (abs (actual_ttl_foo - actual_ttl_bar ) <= 1 )
1544
1548
1545
1549
0 commit comments