6
6
from __future__ import print_function
7
7
from __future__ import unicode_literals
8
8
import os
9
+ import sys
9
10
10
11
11
12
import subprocess
@@ -97,7 +98,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
97
98
98
99
def test_script_from_stdin_to_stdout ():
99
100
"""Command line utility: read from stdin, print to stdout"""
100
- cmd = ["python" , "tabulate.py" ]
101
+ cmd = [sys . executable , "tabulate.py" ]
101
102
out = run_and_capture_stdout (cmd , input = sample_input ())
102
103
expected = SAMPLE_SIMPLE_FORMAT
103
104
print ("got: " ,repr (out ))
@@ -110,7 +111,7 @@ def test_script_from_file_to_stdout():
110
111
with TemporaryTextFile () as tmpfile :
111
112
tmpfile .write (sample_input ())
112
113
tmpfile .seek (0 )
113
- cmd = ["python" , "tabulate.py" , tmpfile .name ]
114
+ cmd = [sys . executable , "tabulate.py" , tmpfile .name ]
114
115
out = run_and_capture_stdout (cmd )
115
116
expected = SAMPLE_SIMPLE_FORMAT
116
117
print ("got: " ,repr (out ))
@@ -124,7 +125,7 @@ def test_script_from_file_to_file():
124
125
with TemporaryTextFile () as output_file :
125
126
input_file .write (sample_input ())
126
127
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 ]
128
129
out = run_and_capture_stdout (cmd )
129
130
# check that nothing is printed to stdout
130
131
expected = ""
@@ -143,7 +144,7 @@ def test_script_from_file_to_file():
143
144
def test_script_header_option ():
144
145
"""Command line utility: -1, --header option"""
145
146
for option in ["-1" , "--header" ]:
146
- cmd = ["python" , "tabulate.py" , option ]
147
+ cmd = [sys . executable , "tabulate.py" , option ]
147
148
raw_table = sample_input (with_headers = True )
148
149
out = run_and_capture_stdout (cmd , input = raw_table )
149
150
expected = SAMPLE_SIMPLE_FORMAT_WITH_HEADERS
@@ -156,7 +157,7 @@ def test_script_header_option():
156
157
def test_script_sep_option ():
157
158
"""Command line utility: -s, --sep option"""
158
159
for option in ["-s" , "--sep" ]:
159
- cmd = ["python" , "tabulate.py" , option , "," ]
160
+ cmd = [sys . executable , "tabulate.py" , option , "," ]
160
161
raw_table = sample_input (sep = "," )
161
162
out = run_and_capture_stdout (cmd , input = raw_table )
162
163
expected = SAMPLE_SIMPLE_FORMAT
@@ -168,7 +169,7 @@ def test_script_sep_option():
168
169
def test_script_floatfmt_option ():
169
170
"""Command line utility: -F, --float option"""
170
171
for option in ["-F" , "--float" ]:
171
- cmd = ["python" , "tabulate.py" , option , ".1e" , "--format" , "grid" ]
172
+ cmd = [sys . executable , "tabulate.py" , option , ".1e" , "--format" , "grid" ]
172
173
raw_table = sample_input ()
173
174
out = run_and_capture_stdout (cmd , input = raw_table )
174
175
expected = SAMPLE_GRID_FORMAT_WITH_DOT1E_FLOATS
@@ -180,7 +181,7 @@ def test_script_floatfmt_option():
180
181
def test_script_format_option ():
181
182
"""Command line utility: -f, --format option"""
182
183
for option in ["-f" , "--format" ]:
183
- cmd = ["python" , "tabulate.py" , "-1" , option , "grid" ]
184
+ cmd = [sys . executable , "tabulate.py" , "-1" , option , "grid" ]
184
185
raw_table = sample_input (with_headers = True )
185
186
out = run_and_capture_stdout (cmd , input = raw_table )
186
187
expected = SAMPLE_GRID_FORMAT_WITH_HEADERS
0 commit comments