Skip to content

Commit 6f7daad

Browse files
Kelledinilevkivskyi
authored andcommitted
* fix tests for non-default interpreters (#662)
`test_typing_compiles_with_opt()` is prone to failure if building and testing with an interpreter that doesn't match the default python in $PATH (for example, if running `python3 setup.py ...` when the default system-wide interpreter is Python 2.x). Using `sys.executable` (vs hardcoded unversioned "python") seems to be the most sensible solution.
1 parent f254d69 commit 6f7daad

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

python2/test_typing.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,9 +2676,8 @@ def test_typing_compiles_with_opt(self):
26762676
file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
26772677
'typing.py')
26782678
try:
2679-
subprocess.check_output('python -OO {}'.format(file_path),
2680-
stderr=subprocess.STDOUT,
2681-
shell=True)
2679+
subprocess.check_output([sys.executable, '-OO', file_path],
2680+
stderr=subprocess.STDOUT)
26822681
except subprocess.CalledProcessError:
26832682
self.fail('Module does not compile with optimize=2 (-OO flag).')
26842683

src/test_typing.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,9 +2653,8 @@ def test_typing_compiles_with_opt(self):
26532653
file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
26542654
'typing.py')
26552655
try:
2656-
subprocess.check_output('python -OO {}'.format(file_path),
2657-
stderr=subprocess.STDOUT,
2658-
shell=True)
2656+
subprocess.check_output([sys.executable, '-OO', file_path],
2657+
stderr=subprocess.STDOUT)
26592658
except subprocess.CalledProcessError:
26602659
self.fail('Module does not compile with optimize=2 (-OO flag).')
26612660

0 commit comments

Comments
 (0)