[Pkg-privacy-commits] [txtorcon] 22/49: at least call TorState error-handler in a test

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 0e25cd933802fb5854e81ba78d89d950534bc494
Author: meejah <meejah at meejah.ca>
Date:   Fri Jun 19 16:29:36 2015 -0600

    at least call TorState error-handler in a test
---
 test/test_torstate.py | 8 ++++++++
 txtorcon/torstate.py  | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/test/test_torstate.py b/test/test_torstate.py
index a46da41..d04202c 100644
--- a/test/test_torstate.py
+++ b/test/test_torstate.py
@@ -2,12 +2,15 @@ from zope.interface import implements
 from zope.interface.verify import verifyClass
 from twisted.trial import unittest
 from twisted.test import proto_helpers
+from twisted.python.failure import Failure
 from twisted.internet import task, defer
 from twisted.internet.interfaces import IStreamClientEndpoint, IReactorCore
 
 import os
 import tempfile
 
+from mock import patch
+
 from txtorcon import TorControlProtocol
 from txtorcon import TorProtocolError
 from txtorcon import TorState
@@ -333,6 +336,11 @@ class StateTests(unittest.TestCase):
         self.state.set_attacher(attacher, FakeReactor(self))
         self.state._stream_update("76 CLOSED 0 www.example.com:0 REASON=DONE")
 
+    def test_attacher_error_handler(self):
+        # make sure error-handling "does something" that isn't blowing up
+        with patch('sys.stdout') as fake_stdout:
+            TorState(self.protocol)._attacher_error(Failure(RuntimeError("quote")))
+
     def test_stream_update(self):
         # we use a circuit ID of 0 so it doesn't try to look anything
         # up but it's not really correct to have a SUCCEEDED w/o a
diff --git a/txtorcon/torstate.py b/txtorcon/torstate.py
index 64ac074..4ef1f60 100644
--- a/txtorcon/torstate.py
+++ b/txtorcon/torstate.py
@@ -660,6 +660,8 @@ class TorState(object):
         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.
+
+        tests monkey-patch this to reduce spew
         """
         print "Failure while attaching stream:", fail
         return fail

-- 
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