zconfig@zope.org
[Top] [All Lists]

[Zconfig] SVN: ZConfig/branches/LP-481512-reopen-logs/ZConfig/components

Subject: [Zconfig] SVN: ZConfig/branches/LP-481512-reopen-logs/ZConfig/components/logger/tests/test_logger.py - capture ordering of calls to acquire/release
From: Fred Drake
Date: Sat, 11 Feb 2012 00:40:24 -0500 EST
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):

_______________________________________________
ZConfig mailing list
ZConfig@xxxxxxxx
https://mail.zope.org/mailman/listinfo/zconfig

<Prev in Thread] Current Thread [Next in Thread>
  • [Zconfig] SVN: ZConfig/branches/LP-481512-reopen-logs/ZConfig/components/logger/tests/test_logger.py - capture ordering of calls to acquire/release, Fred Drake <=