[Pkg-privacy-commits] [txtorcon] 34/49: use official mock API
Ximin Luo
infinity0 at debian.org
Mon Oct 19 13:49:53 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 b7b3632a97157d2892ec081220fb87ecbe6d7c80
Author: meejah <meejah at meejah.ca>
Date: Sat Sep 5 23:53:44 2015 -0600
use official mock API
---
test/test_endpoints.py | 12 +++++++-----
test/test_torconfig.py | 2 +-
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/test/test_endpoints.py b/test/test_endpoints.py
index d538da3..4fe193d 100644
--- a/test/test_endpoints.py
+++ b/test/test_endpoints.py
@@ -115,7 +115,7 @@ class EndpointTests(unittest.TestCase):
endpoints.launch_tor = m
ep = yield TCPHiddenServiceEndpoint.private_tor(Mock(), 80,
control_port=1234)
- m.assert_called()
+ self.assertTrue(m.called)
@defer.inlineCallbacks
def test_private_tor_no_control_port(self):
@@ -123,7 +123,7 @@ class EndpointTests(unittest.TestCase):
from txtorcon import endpoints
endpoints.launch_tor = m
ep = yield TCPHiddenServiceEndpoint.private_tor(Mock(), 80)
- m.assert_called()
+ self.assertTrue(m.called)
@defer.inlineCallbacks
def test_system_tor(self):
@@ -136,7 +136,7 @@ class EndpointTests(unittest.TestCase):
def bam(*args, **kw):
return self.protocol
return bam
- with patch('txtorcon.endpoints.launch_tor') as m:
+ with patch('txtorcon.endpoints.launch_tor') as launch_mock:
with patch('txtorcon.endpoints.build_tor_connection', new_callable=boom) as btc:
client = clientFromString(
self.reactor,
@@ -151,7 +151,9 @@ class EndpointTests(unittest.TestCase):
port.startListening()
str(port)
port.tor_config
- m.assert_called()
+ # system_tor should be connecting to a running one,
+ # *not* launching a new one.
+ self.assertFalse(launch_mock.called)
@defer.inlineCallbacks
def test_basic(self):
@@ -185,7 +187,7 @@ class EndpointTests(unittest.TestCase):
args = (50, "blarg", "Doing that thing we talked about.")
# kind-of cheating, test-wise?
ep._tor_progress_update(*args)
- ding.assert_called_with(*args)
+ self.assertTrue(ding.called_with(*args))
@patch('txtorcon.endpoints.launch_tor')
def test_progress_updates_private_tor(self, tor):
diff --git a/test/test_torconfig.py b/test/test_torconfig.py
index 278a1b1..df329fe 100644
--- a/test/test_torconfig.py
+++ b/test/test_torconfig.py
@@ -1086,7 +1086,7 @@ ControlPort Port''')
tpp.timeout_expired()
- tpp.transport.loseConnection.assert_called()
+ self.assertTrue(tpp.transport.loseConnection.called)
@defer.inlineCallbacks
def test_launch_timeout_process_exits(self):
--
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