Skip to content
Snippets Groups Projects
Commit 7a09b770 authored by Damian Johnson's avatar Damian Johnson
Browse files

test_no_orphaned_process failed if no tor binary was on the path

Oops, we forgot to pass the tor path into one of the process tests...

  https://trac.torproject.org/projects/tor/ticket/22894
parent d6378fab
Branches
Tags
No related merge requests found
......@@ -258,14 +258,17 @@ class TestProcess(unittest.TestCase):
elif 'UseBridges' not in output or 'SocksPort' not in output:
raise AssertionError("'tor --list-torrc-options' didn't have options we expect")
@test.require.command('sleep')
@patch('re.compile', Mock(side_effect = KeyboardInterrupt('nope')))
def test_no_orphaned_process(self):
@asynchronous
def test_no_orphaned_process(tor_cmd):
"""
Check that when an exception arises in the middle of spawning tor that we
don't leave a lingering process.
"""
if not stem.util.system.is_available('sleep'):
skip('(sleep unavailable)')
with patch('re.compile', Mock(side_effect = KeyboardInterrupt('nope'))):
# We don't need to actually run tor for this test. Rather, any process will
# do the trick. Picking sleep so this'll clean itself up if our test fails.
......@@ -273,13 +276,13 @@ class TestProcess(unittest.TestCase):
with patch('subprocess.Popen', Mock(return_value = mock_tor_process)):
try:
stem.process.launch_tor()
self.fail("tor shoudn't have started")
stem.process.launch_tor(tor_cmd)
raise AssertionError("tor shoudn't have started")
except KeyboardInterrupt as exc:
if os.path.exists('/proc/%s' % mock_tor_process.pid):
self.fail('launch_tor() left a lingering tor process')
raise AssertionError('launch_tor() left a lingering tor process')
self.assertEqual('nope', str(exc))
assert_equal('nope', str(exc))
@asynchronous
def test_torrc_arguments(tor_cmd):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment