Rev 166: Add ConnectionLogger.connectToNamedSlot in http://bazaar.launchpad.net/~jameinel/bzr-explorer/basic-tests

John Arbash Meinel john at arbash-meinel.com
Wed Jul 8 21:28:15 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr-explorer/basic-tests

------------------------------------------------------------
revno: 166
revision-id: john at arbash-meinel.com-20090708202810-7k51txb3t0t2qggj
parent: john at arbash-meinel.com-20090708200005-9lf1fud4k91pi1am
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: basic-tests
timestamp: Wed 2009-07-08 15:28:10 -0500
message:
  Add ConnectionLogger.connectToNamedSlot
  
  This just makes it a lot shorter to hook up a bunch of signals.
-------------- next part --------------
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2009-07-08 20:00:05 +0000
+++ b/tests/__init__.py	2009-07-08 20:28:10 +0000
@@ -61,6 +61,17 @@
                 def named_slot(*args):
                     self.log.append((signal_name,) + args)
                 return named_slot
+
+            def connectToNamedSlot(self, signal, source):
+                """Create a new named slot, and connect the signal from source.
+
+                :param signal: The value to pass to QtCore.SIGNAL, this will
+                    also be the name logged when the signal is activated.
+                :param source: An object that can generate the given signal.
+                """
+                slot = self.createNamedSlot(signal)
+                QtCore.QObject.connect(source, QtCore.SIGNAL(signal), slot)
+
         return ConnectionLogger(*args)
 
 

=== modified file 'tests/test_test_suite.py'
--- a/tests/test_test_suite.py	2009-07-08 20:00:05 +0000
+++ b/tests/test_test_suite.py	2009-07-08 20:28:10 +0000
@@ -53,3 +53,14 @@
         self.assertEqual([('trapping_foo',), ('trapping_foo',),
                           ('trapping_bar', 1, 2),
                          ], self.logger.log)
+
+    def test_connectToNamedSlot(self):
+        emitter = _Emitter()
+        self.logger.connectToNamedSlot('foo()', emitter)
+        self.logger.connectToNamedSlot('bar(int, int)', emitter)
+        emitter.trigger_foo()
+        self.assertEqual([('foo()',)], self.logger.log)
+        emitter.trigger_bar(3, 4)
+        self.assertEqual([('foo()',), ('bar(int, int)', 3, 4)],
+                         self.logger.log)
+



More information about the bazaar-commits mailing list