|
1 | 1 | import sys
|
2 | 2 | from collections import namedtuple
|
| 3 | +from unittest import TestCase |
3 | 4 |
|
4 | 5 | import mock
|
5 | 6 | import pytest
|
@@ -70,7 +71,7 @@ def osutils():
|
70 | 71 |
|
71 | 72 | class FakePopen(object):
|
72 | 73 | def __init__(self, rc, out, err):
|
73 |
| - self.returncode = 0 |
| 74 | + self.returncode = rc |
74 | 75 | self._out = out
|
75 | 76 | self._err = err
|
76 | 77 |
|
@@ -303,14 +304,24 @@ def test_inject_unknown_error_if_no_stderr(self, pip_factory):
|
303 | 304 | assert str(einfo.value) == 'Unknown error'
|
304 | 305 |
|
305 | 306 |
|
306 |
| -class TestSubprocessPip(object): |
| 307 | +class TestSubprocessPip(TestCase): |
307 | 308 | def test_does_use_custom_pip_import_string(self):
|
308 | 309 | fake_osutils = FakePopenOSUtils([FakePopen(0, '', '')])
|
309 | 310 | expected_import_statement = 'foobarbaz'
|
310 | 311 | pip = SubprocessPip(osutils=fake_osutils,
|
311 |
| - import_string=expected_import_statement) |
| 312 | + import_string=expected_import_statement, |
| 313 | + python_exe=sys.executable) |
312 | 314 | pip.main(['--version'])
|
313 | 315 |
|
314 | 316 | pip_execution_string = fake_osutils.popens[0][0][0][2]
|
315 | 317 | import_statement = pip_execution_string.split(';')[1].strip()
|
316 | 318 | assert import_statement == expected_import_statement
|
| 319 | + |
| 320 | + def test_check_pip_runner_string_pip(self): |
| 321 | + fake_osutils = FakePopenOSUtils([FakePopen(0, '', '')]) |
| 322 | + pip = SubprocessPip(osutils=fake_osutils, |
| 323 | + python_exe=sys.executable) |
| 324 | + pip.main(['--version']) |
| 325 | + |
| 326 | + pip_runner_string = fake_osutils.popens[0][0][0][2].split(";")[-1:][0] |
| 327 | + self.assertIn("main", pip_runner_string) |
0 commit comments