Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge the finalisation test into the contention test; make it standal…

…one.
  • Loading branch information...
commit 6f708b093499dc6edd037b1e6b3629bba51cea78 1 parent 513d5f2
Keith Gaughan authored September 23, 2012

Showing 1 changed file with 8 additions and 9 deletions. Show diff stats Hide diff stats

  1. 17  tests/test_pools.py
17  tests/test_pools.py
@@ -47,6 +47,7 @@ def test_bad_query():
47 47
 
48 48
 
49 49
 def test_contention():
  50
+    pool = dbkit.Pool(fakedb, 1, fakedb.INVALID_CURSOR)
50 51
     # Here, we're testing that the pool behaves properly when it hits its
51 52
     # maximum number of connections and a thread it waiting for another one
52 53
     # to release the connection it's currently using.
@@ -54,13 +55,13 @@ def test_contention():
54 55
     spawn = threading.Event()
55 56
 
56 57
     def hog_connection():
57  
-        with POOL.connect() as ctx:
  58
+        with pool.connect() as ctx:
58 59
             with dbkit.transaction():
59 60
                 spawn.set()
60 61
                 release.wait()
61 62
 
62 63
     def wait_on_connection():
63  
-        with POOL.connect() as ctx:
  64
+        with pool.connect() as ctx:
64 65
             spawn.wait()
65 66
             # Request the other thread to release the connection after a
66 67
             # short period, enough to ensure the conditional variable
@@ -79,13 +80,11 @@ def wait_on_connection():
79 80
                 pass
80 81
     utils.spawn([wait_on_connection, hog_connection])
81 82
 
82  
-
83  
-def test_finalise():
84  
-    assert POOL._allocated == 1
85  
-    assert len(POOL._pool) == 1
86  
-    POOL.finalise()
87  
-    assert POOL._allocated == 0
88  
-    assert len(POOL._pool) == 0
  83
+    assert pool._allocated == 1
  84
+    assert len(pool._pool) == 1
  85
+    pool.finalise()
  86
+    assert pool._allocated == 0
  87
+    assert len(pool._pool) == 0
89 88
 
90 89
 
91 90
 def test_setting_propagation():

0 notes on commit 6f708b0

Please sign in to comment.
Something went wrong with that request. Please try again.