@@ -14,7 +14,7 @@ class test_alock(unittest.TestCase):
1414 def testALockWait (self ):
1515 # sadly, this is primarily used to exercise the code paths..
1616 ad = prepare (n_alocks ).first
17- self .failUnlessEqual (ad (), 0 )
17+ self .assertEqual (ad (), 0 )
1818 state = [False , False , False ]
1919 alt = new ()
2020 first = alock .ExclusiveLock (db , (0 ,0 ))
@@ -37,31 +37,31 @@ def concurrent_lock():
3737 t .start ()
3838 while not state [0 ]:
3939 time .sleep (0.01 )
40- self .failUnlessEqual (ad (), 2 )
40+ self .assertEqual (ad (), 2 )
4141 state [1 ] = True
4242 with first :
43- self .failUnlessEqual (ad (), 2 )
43+ self .assertEqual (ad (), 2 )
4444 state [2 ] = True
4545 with second :
46- self .failUnlessEqual (ad (), 2 )
46+ self .assertEqual (ad (), 2 )
4747 t .join (timeout = 1 )
4848
4949 @pg_tmp
5050 def testALockNoWait (self ):
5151 alt = new ()
5252 ad = prepare (n_alocks ).first
53- self .failUnlessEqual (ad (), 0 )
53+ self .assertEqual (ad (), 0 )
5454 with alock .ExclusiveLock (db , (0 ,0 )):
5555 l = alock .ExclusiveLock (alt , (0 ,0 ))
5656 # should fail to acquire
57- self .failUnlessEqual (l .acquire (blocking = False ), False )
57+ self .assertEqual (l .acquire (blocking = False ), False )
5858 # no alocks should exist now
59- self .failUnlessEqual (ad (), 0 )
59+ self .assertEqual (ad (), 0 )
6060
6161 @pg_tmp
6262 def testALock (self ):
6363 ad = prepare (n_alocks ).first
64- self .failUnlessEqual (ad (), 0 )
64+ self .assertEqual (ad (), 0 )
6565 # test a variety..
6666 lockids = [
6767 (1 ,4 ),
@@ -77,62 +77,62 @@ def testALock(self):
7777 sal1 = alock .ShareLock (db , * lockids )
7878 with sal1 :
7979 with xal1 , xal2 :
80- self .failUnless (ad () > 0 )
80+ self .assertTrue (ad () > 0 )
8181 for x in lockids :
8282 xl = alock .ExclusiveLock (alt , x )
83- self .failUnlessEqual (xl .acquire (blocking = False ), False )
83+ self .assertEqual (xl .acquire (blocking = False ), False )
8484 # main has exclusives on these, so this should fail.
8585 xl = alock .ShareLock (alt , * lockids )
86- self .failUnlessEqual (xl .acquire (blocking = False ), False )
86+ self .assertEqual (xl .acquire (blocking = False ), False )
8787 for x in lockids :
8888 # sal1 still holds
8989 xl = alock .ExclusiveLock (alt , x )
90- self .failUnlessEqual (xl .acquire (blocking = False ), False )
90+ self .assertEqual (xl .acquire (blocking = False ), False )
9191 # sal1 still holds, but we want a share lock too.
9292 xl = alock .ShareLock (alt , x )
93- self .failUnlessEqual (xl .acquire (blocking = False ), True )
93+ self .assertEqual (xl .acquire (blocking = False ), True )
9494 xl .release ()
9595 # no alocks should exist now
96- self .failUnlessEqual (ad (), 0 )
96+ self .assertEqual (ad (), 0 )
9797
9898 @pg_tmp
9999 def testPartialALock (self ):
100100 # Validates that release is properly cleaning up
101101 ad = prepare (n_alocks ).first
102- self .failUnlessEqual (ad (), 0 )
102+ self .assertEqual (ad (), 0 )
103103 held = (0 ,- 1234 )
104104 wanted = [0 , 324 , - 1232948 , 7 , held , 1 , (2 ,4 ), (834 ,1 )]
105105 alt = new ()
106106 with alock .ExclusiveLock (db , held ):
107107 l = alock .ExclusiveLock (alt , * wanted )
108108 # should fail to acquire, db has held
109- self .failUnlessEqual (l .acquire (blocking = False ), False )
109+ self .assertEqual (l .acquire (blocking = False ), False )
110110 # No alocks should exist now.
111111 # This *MUST* occur prior to alt being closed.
112112 # Otherwise, we won't be testing for the recovery
113113 # of a failed non-blocking acquire().
114- self .failUnlessEqual (ad (), 0 )
114+ self .assertEqual (ad (), 0 )
115115
116116 @pg_tmp
117117 def testALockParameterErrors (self ):
118- self .failUnlessRaises (TypeError , alock .ALock )
118+ self .assertRaises (TypeError , alock .ALock )
119119 l = alock .ExclusiveLock (db )
120- self .failUnlessRaises (RuntimeError , l .release )
120+ self .assertRaises (RuntimeError , l .release )
121121
122122 @pg_tmp
123123 def testALockOnClosed (self ):
124124 ad = prepare (n_alocks ).first
125- self .failUnlessEqual (ad (), 0 )
125+ self .assertEqual (ad (), 0 )
126126 held = (0 ,- 1234 )
127127 alt = new ()
128128 # __exit__ should only touch the count.
129129 with alock .ExclusiveLock (alt , held ) as l :
130- self .failUnlessEqual (ad (), 1 )
131- self .failUnlessEqual (l .locked (), True )
130+ self .assertEqual (ad (), 1 )
131+ self .assertEqual (l .locked (), True )
132132 alt .close ()
133133 time .sleep (0.005 )
134- self .failUnlessEqual (ad (), 0 )
135- self .failUnlessEqual (l .locked (), False )
134+ self .assertEqual (ad (), 0 )
135+ self .assertEqual (l .locked (), False )
136136
137137if __name__ == '__main__' :
138138 unittest .main ()
0 commit comments