Skip to content

Commit b99637d

Browse files
authored
Merge pull request #2 from jayvdb/i1
test_cli: Use sys.executable
2 parents a4c2226 + c8d491e commit b99637d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

test/test_cli.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from __future__ import print_function
77
from __future__ import unicode_literals
88
import os
9+
import sys
910

1011

1112
import subprocess
@@ -97,7 +98,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
9798

9899
def test_script_from_stdin_to_stdout():
99100
"""Command line utility: read from stdin, print to stdout"""
100-
cmd = ["python", "tabulate.py"]
101+
cmd = [sys.executable, "tabulate.py"]
101102
out = run_and_capture_stdout(cmd, input=sample_input())
102103
expected = SAMPLE_SIMPLE_FORMAT
103104
print("got: ",repr(out))
@@ -110,7 +111,7 @@ def test_script_from_file_to_stdout():
110111
with TemporaryTextFile() as tmpfile:
111112
tmpfile.write(sample_input())
112113
tmpfile.seek(0)
113-
cmd = ["python", "tabulate.py", tmpfile.name]
114+
cmd = [sys.executable, "tabulate.py", tmpfile.name]
114115
out = run_and_capture_stdout(cmd)
115116
expected = SAMPLE_SIMPLE_FORMAT
116117
print("got: ",repr(out))
@@ -124,7 +125,7 @@ def test_script_from_file_to_file():
124125
with TemporaryTextFile() as output_file:
125126
input_file.write(sample_input())
126127
input_file.seek(0)
127-
cmd = ["python", "tabulate.py", "-o", output_file.name, input_file.name]
128+
cmd = [sys.executable, "tabulate.py", "-o", output_file.name, input_file.name]
128129
out = run_and_capture_stdout(cmd)
129130
# check that nothing is printed to stdout
130131
expected = ""
@@ -143,7 +144,7 @@ def test_script_from_file_to_file():
143144
def test_script_header_option():
144145
"""Command line utility: -1, --header option"""
145146
for option in ["-1", "--header"]:
146-
cmd = ["python", "tabulate.py", option]
147+
cmd = [sys.executable, "tabulate.py", option]
147148
raw_table = sample_input(with_headers=True)
148149
out = run_and_capture_stdout(cmd, input=raw_table)
149150
expected = SAMPLE_SIMPLE_FORMAT_WITH_HEADERS
@@ -156,7 +157,7 @@ def test_script_header_option():
156157
def test_script_sep_option():
157158
"""Command line utility: -s, --sep option"""
158159
for option in ["-s", "--sep"]:
159-
cmd = ["python", "tabulate.py", option, ","]
160+
cmd = [sys.executable, "tabulate.py", option, ","]
160161
raw_table = sample_input(sep=",")
161162
out = run_and_capture_stdout(cmd, input=raw_table)
162163
expected = SAMPLE_SIMPLE_FORMAT
@@ -168,7 +169,7 @@ def test_script_sep_option():
168169
def test_script_floatfmt_option():
169170
"""Command line utility: -F, --float option"""
170171
for option in ["-F", "--float"]:
171-
cmd = ["python", "tabulate.py", option, ".1e", "--format", "grid"]
172+
cmd = [sys.executable, "tabulate.py", option, ".1e", "--format", "grid"]
172173
raw_table = sample_input()
173174
out = run_and_capture_stdout(cmd, input=raw_table)
174175
expected = SAMPLE_GRID_FORMAT_WITH_DOT1E_FLOATS
@@ -180,7 +181,7 @@ def test_script_floatfmt_option():
180181
def test_script_format_option():
181182
"""Command line utility: -f, --format option"""
182183
for option in ["-f", "--format"]:
183-
cmd = ["python", "tabulate.py", "-1", option, "grid"]
184+
cmd = [sys.executable, "tabulate.py", "-1", option, "grid"]
184185
raw_table = sample_input(with_headers=True)
185186
out = run_and_capture_stdout(cmd, input=raw_table)
186187
expected = SAMPLE_GRID_FORMAT_WITH_HEADERS

0 commit comments

Comments
 (0)