|
18 | 18 | from pre_commit.commands.install_uninstall import PRIOR_HASHES |
19 | 19 | from pre_commit.commands.install_uninstall import shebang |
20 | 20 | from pre_commit.commands.install_uninstall import uninstall |
21 | | -from pre_commit.languages import python |
22 | 21 | from pre_commit.util import cmd_output |
23 | 22 | from pre_commit.util import make_executable |
24 | 23 | from pre_commit.util import mkdirp |
@@ -51,17 +50,19 @@ def test_shebang_windows(): |
51 | 50 | assert shebang() == '#!/usr/bin/env python' |
52 | 51 |
|
53 | 52 |
|
54 | | -def test_shebang_otherwise(): |
| 53 | +def test_shebang_posix_not_on_path(): |
55 | 54 | with mock.patch.object(sys, 'platform', 'posix'): |
56 | | - assert C.DEFAULT not in shebang() |
| 55 | + with mock.patch.object(os, 'defpath', ''): |
| 56 | + assert shebang() == '#!/usr/bin/env python' |
| 57 | + |
57 | 58 |
|
| 59 | +def test_shebang_posix_on_path(tmpdir): |
| 60 | + tmpdir.join('python{}'.format(sys.version_info[0])).ensure() |
58 | 61 |
|
59 | | -def test_shebang_returns_default(): |
60 | 62 | with mock.patch.object(sys, 'platform', 'posix'): |
61 | | - with mock.patch.object( |
62 | | - python, 'get_default_version', return_value=C.DEFAULT, |
63 | | - ): |
64 | | - assert shebang() == '#!/usr/bin/env python' |
| 63 | + with mock.patch.object(os, 'defpath', tmpdir.strpath): |
| 64 | + expected = '#!/usr/bin/env python{}'.format(sys.version_info[0]) |
| 65 | + assert shebang() == expected |
65 | 66 |
|
66 | 67 |
|
67 | 68 | def test_install_pre_commit(in_git_dir, store): |
|
0 commit comments