[Pkg-privacy-commits] [txtorcon] 20/49: slightly-better error-handling to avoid spew in tests

Ximin Luo infinity0 at debian.org
Mon Oct 19 13:49:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository txtorcon.

commit e6dd2a2c53cc677024b23b8ffcd81c8a6f3a718d
Author: meejah <meejah at meejah.ca>
Date:   Mon Jun 1 11:59:52 2015 -0600

    slightly-better error-handling to avoid spew in tests
---
 test/test_torstate.py |  2 ++
 txtorcon/torstate.py  | 19 +++++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/test/test_torstate.py b/test/test_torstate.py
index d526826..a46da41 100644
--- a/test/test_torstate.py
+++ b/test/test_torstate.py
@@ -312,6 +312,8 @@ class StateTests(unittest.TestCase):
     def setUp(self):
         self.protocol = TorControlProtocol()
         self.state = TorState(self.protocol)
+        # avoid spew in trial logs; state prints this by default
+        self.state._attacher_error = lambda f: f
         self.protocol.connectionMade = lambda: None
         self.transport = proto_helpers.StringTransport()
         self.protocol.makeConnection(self.transport)
diff --git a/txtorcon/torstate.py b/txtorcon/torstate.py
index fd73992..64ac074 100644
--- a/txtorcon/torstate.py
+++ b/txtorcon/torstate.py
@@ -650,17 +650,20 @@ class TorState(object):
                     "ATTACHSTREAM %d %d" % (stream.id, circ.id)
                 )
 
-        # not ideal, but there's not really a good way to let the
-        # caller handler errors :/ since we ultimately call this due
-        # to an async request from Tor. Mostly these errors will be
-        # logic or syntax errors in the caller's code anyway.
-        def _error(f):
-            print "Failure while attaching stream:", f
-            return f
         circ_d.addCallback(issue_stream_attach)
-        circ_d.addErrback(_error)
+        circ_d.addErrback(self._attacher_error)
         return circ_d
 
+    def _attacher_error(self, fail):
+        """
+        not ideal, but there's not really a good way to let the caller
+        handler errors :/ since we ultimately call this due to an
+        async request from Tor. Mostly these errors will be logic or
+        syntax errors in the caller's code anyway.
+        """
+        print "Failure while attaching stream:", fail
+        return fail
+
     def _circuit_status(self, data):
         """Used internally as a callback for updating Circuit information"""
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/txtorcon.git



More information about the Pkg-privacy-commits mailing list