Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion python/subunit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,12 @@ def debug(self):

def _run(self, result):
protocol = TestProtocolServer(result)
process = subprocess.Popen(self.script, shell=True, stdout=subprocess.PIPE)
# Explicitly invoke Python to run the script instead of relying on
# execute permissions, which may not be preserved during installation
import shlex

script_parts = shlex.split(self.script)
process = subprocess.Popen([sys.executable] + script_parts, stdout=subprocess.PIPE)
make_stream_binary(process.stdout)
output = process.communicate()[0]
protocol.readFrom(BytesIO(output))
Expand Down
17 changes: 12 additions & 5 deletions python/subunit/tests/test_test_protocol2.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
from testtools import TestCase
from testtools.matchers import Contains, HasLength
from testtools.testresult.doubles import StreamResult
from testtools.tests.test_testresult import TestStreamResultContract

try:
from testtools.tests.test_testresult import TestStreamResultContract
except ImportError:
# testtools >= 2.8 no longer includes the tests submodule
TestStreamResultContract = None

import subunit
import iso8601
Expand All @@ -54,11 +59,13 @@
]


class TestStreamResultToBytesContract(TestCase, TestStreamResultContract):
"""Check that StreamResult behaves as testtools expects."""
if TestStreamResultContract is not None:

def _make_result(self):
return subunit.StreamResultToBytes(BytesIO())
class TestStreamResultToBytesContract(TestCase, TestStreamResultContract):
"""Check that StreamResult behaves as testtools expects."""

def _make_result(self):
return subunit.StreamResultToBytes(BytesIO())


class TestStreamResultToBytes(TestCase):
Expand Down