Skip to content

Commit

Permalink
Tor.process property returns None instead of exception
Browse files Browse the repository at this point in the history
  • Loading branch information
meejah committed Jun 19, 2018
1 parent 37e4d9b commit a12424c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions test/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,9 +1073,10 @@ def setUp(self):
self.tor = Tor(reactor, proto, _tor_config=self.cfg)

def test_process(self):
with self.assertRaises(Exception) as ctx:
self.assertIs(
None,
self.tor.process
self.assertTrue('not launched by us' in str(ctx.exception))
)

def test_when_connected_already(self):
tpp = TorProcessProtocol(lambda: None)
Expand Down
9 changes: 6 additions & 3 deletions txtorcon/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,14 @@ def quit(self):

@property
def process(self):
"""
An object implementing
:api:`twisted.internet.interfaces.IProcessProtocol` if this
Tor instance was launched, or None.
"""
if self._process_protocol:
return self._process_protocol
raise RuntimeError(
"This Tor instance was not launched by us; no process to return"
)
return None

@property
def protocol(self):
Expand Down

0 comments on commit a12424c

Please sign in to comment.