def test_symlink_other_python(self): if os.name == 'nt': raise SkipTest('symlink') (self.tmpdir / 'site-packages2').mkdir() (self.tmpdir / 'scripts2').mkdir() # Called by Installer._auto_user() : script1 = ("#!{python}\n" "import sysconfig\n" "print(True)\n" # site.ENABLE_USER_SITE "print({purelib!r})" # sysconfig.get_path('purelib') ).format(python=sys.executable, purelib=str(self.tmpdir / 'site-packages2')) # Called by Installer._get_dirs() : script2 = ("#!{python}\n" "import json, sys\n" "json.dump({{'purelib': {purelib!r}, 'scripts': {scripts!r} }}, " "sys.stdout)" ).format(python=sys.executable, purelib=str(self.tmpdir / 'site-packages2'), scripts=str(self.tmpdir / 'scripts2')) with MockCommand('mock_python', content=script1): ins = Installer(samples_dir / 'package1' / 'flit.ini', python='mock_python', symlink=True) with MockCommand('mock_python', content=script2): ins.install() assert_islink(self.tmpdir / 'site-packages2' / 'package1', to=samples_dir / 'package1' / 'package1') assert_isfile(self.tmpdir / 'scripts2' / 'pkg_script') with (self.tmpdir / 'scripts2' / 'pkg_script').open() as f: assert f.readline().strip() == "#!mock_python"
def test_pip_install(self): ins = Installer(samples_dir / 'package1' / 'flit.ini', python='mock_python', user=False) with MockCommand('mock_python') as mock_py: ins.install() calls = mock_py.get_calls() assert len(calls) == 1 cmd = calls[0]['argv'] assert cmd[1:4] == ['-m', 'pip', 'install'] assert cmd[4].endswith('package1-0.1-py2.py3-none-any.whl')