1
0
forked from pool/python-mutmut
python-mutmut/pr_148.patch

63 lines
2.1 KiB
Diff

From b963cf66e26599fa7ac4a1646dd1be5704624673 Mon Sep 17 00:00:00 2001
From: John Vandenberg <jayvdb@gmail.com>
Date: Wed, 4 Sep 2019 12:37:28 +0700
Subject: [PATCH] test_main: Use sys.executable
Avoids test failures related to multiple pythons,
especially when the `python` executable is Python 2.
---
tests/test_main.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
Index: mutmut-1.5.1/tests/test_main.py
===================================================================
--- mutmut-1.5.1.orig/tests/test_main.py
+++ mutmut-1.5.1/tests/test_main.py
@@ -20,6 +20,7 @@ try:
except ImportError:
from mock import MagicMock, call
+PYTHON = '"{}"'.format(sys.executable)
file_to_mutate_lines = [
"def foo(a, b):",
@@ -168,7 +169,10 @@ def test_python_source_files__with_paths
def test_popen_streaming_output_timeout():
start = time()
with pytest.raises(TimeoutError):
- popen_streaming_output('python -c "import time; time.sleep(4)"', lambda line: line, timeout=0.1)
+ popen_streaming_output(
+ PYTHON + ' -c "import time; time.sleep(4)"',
+ lambda line: line, timeout=0.1,
+ )
assert (time() - start) < 3
@@ -176,20 +180,23 @@ def test_popen_streaming_output_timeout(
def test_popen_streaming_output_stream():
mock = MagicMock()
popen_streaming_output(
- 'python -c "print(\'first\'); print(\'second\')"',
+ PYTHON + ' -c "print(\'first\'); print(\'second\')"',
callback=mock
)
mock.assert_has_calls([call('first'), call('second')])
mock = MagicMock()
popen_streaming_output(
- 'python -c "import time; print(\'first\'); time.sleep(1); print(\'second\'); print(\'third\')"',
+ PYTHON +
+ ' -c "import time; print(\'first\'); time.sleep(1); print(\'second\'); print(\'third\')"',
callback=mock
)
mock.assert_has_calls([call('first'), call('second'), call('third')])
mock = MagicMock()
- popen_streaming_output('python -c "exit(0);"', callback=mock)
+ popen_streaming_output(
+ PYTHON + ' -c "exit(0);"',
+ callback=mock)
mock.assert_not_called()