[Checkins] SVN: ZConfig/branches/LP-481512-reopen-logs/ZConfig/components/logger/tests/test_logger.py - capture ordering of calls to acquire/release

Fred Drake fdrake at gmail.com
Sat Feb 11 05:40:24 UTC 2012


Log message for revision 124373:
  - capture ordering of calls to acquire/release
  - simplify test implementation

Changed:
  U   ZConfig/branches/LP-481512-reopen-logs/ZConfig/components/logger/tests/test_logger.py

-=-
Modified: ZConfig/branches/LP-481512-reopen-logs/ZConfig/components/logger/tests/test_logger.py
===================================================================
--- ZConfig/branches/LP-481512-reopen-logs/ZConfig/components/logger/tests/test_logger.py	2012-02-10 21:44:53 UTC (rev 124372)
+++ ZConfig/branches/LP-481512-reopen-logs/ZConfig/components/logger/tests/test_logger.py	2012-02-11 05:40:21 UTC (rev 124373)
@@ -540,24 +540,19 @@
     def test_filehandler_reopen_thread_safety(self):
         # The reopen method needs to do locking to avoid a race condition
         # with emit calls. For simplicity we replace the "acquire" and
-        # "release" calls with dummy method that counts its calls.
-        class FakeMethod(object):
-            def __init__(self):
-                self.call_count = 0
+        # "release" methods with dummies that record calls to them.
 
-            def __call__(self):
-                self.call_count += 1
-
         fn = self.mktemp()
         h = self.handler_factory(fn)
-        h.acquire = FakeMethod()
-        h.release = FakeMethod()
 
+        calls = []
+        h.acquire = lambda: calls.append("acquire")
+        h.release = lambda: calls.append("release")
+
         h.reopen()
         h.close()
 
-        self.assertEqual(1, h.acquire.call_count)
-        self.assertEqual(1, h.release.call_count)
+        self.assertEqual(calls, ["acquire", "release"])
 
 
 class TestReopeningRotatingLogfiles(TestReopeningLogfilesBase):



More information about the checkins mailing list