[CalendarServer-changes] [11476] CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/ test_sendfdport.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jul 5 17:43:09 PDT 2013
Revision: 11476
http://trac.calendarserver.org//changeset/11476
Author: glyph at apple.com
Date: 2013-07-05 17:43:09 -0700 (Fri, 05 Jul 2013)
Log Message:
-----------
Refactor duplication in new tests.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/test_sendfdport.py
Modified: CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/test_sendfdport.py
===================================================================
--- CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/test_sendfdport.py 2013-07-06 00:43:07 UTC (rev 11475)
+++ CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/test_sendfdport.py 2013-07-06 00:43:09 UTC (rev 11476)
@@ -65,6 +65,25 @@
+class Watcher(object):
+ def __init__(self, q):
+ self.q = q
+
+ def newConnectionStatus(self, previous):
+ if previous is None:
+ previous = 0
+ return previous + 1
+
+ def statusFromMessage(self, previous, message):
+ if previous is None:
+ previous = 1
+ return previous - 1
+
+ def statusesChanged(self, statuses):
+ self.q.append(statuses)
+
+
+
class InheritedSocketDispatcherTests(TestCase):
"""
Inherited socket dispatcher tests.
@@ -157,21 +176,8 @@
C{statusWatcher} via C{statusesChanged}.
"""
q = []
- class Watcher(object):
- def newConnectionStatus(self, previous):
- if previous is None:
- previous = 0
- return previous + 1
-
- def statusFromMessage(self, previous, message):
- if previous is None:
- previous = 1
- return previous - 1
-
- def statusesChanged(self, statuses):
- q.append(statuses)
dispatcher = self.dispatcher
- dispatcher.statusWatcher = Watcher()
+ dispatcher.statusWatcher = Watcher(q)
description = "whatever"
# Need to have a socket that will accept the descriptors.
dispatcher.addSocket()
@@ -187,21 +193,8 @@
C{statusesChanged}.
"""
q = []
- class Watcher(object):
- def newConnectionStatus(self, previous):
- if previous is None:
- previous = 0
- return previous + 1
-
- def statusFromMessage(self, previous, message):
- if previous is None:
- previous = 1
- return previous - 1
-
- def statusesChanged(self, statuses):
- q.append(statuses)
dispatcher = self.dispatcher
- dispatcher.statusWatcher = Watcher()
+ dispatcher.statusWatcher = Watcher(q)
message = "whatever"
# Need to have a socket that will accept the descriptors.
dispatcher.addSocket()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130705/d83d53fe/attachment.html>
More information about the calendarserver-changes
mailing list