|
17 | 17 | from pre_commit.commands.install_uninstall import install_hooks |
18 | 18 | from pre_commit.commands.install_uninstall import is_our_script |
19 | 19 | from pre_commit.commands.install_uninstall import PRIOR_HASHES |
| 20 | +from pre_commit.commands.install_uninstall import shebang |
20 | 21 | from pre_commit.commands.install_uninstall import uninstall |
| 22 | +from pre_commit.languages import python |
21 | 23 | from pre_commit.runner import Runner |
22 | 24 | from pre_commit.util import cmd_output |
23 | 25 | from pre_commit.util import make_executable |
@@ -45,6 +47,24 @@ def test_is_previous_pre_commit(tmpdir): |
45 | 47 | assert is_our_script(f.strpath) |
46 | 48 |
|
47 | 49 |
|
| 50 | +def test_shebang_windows(): |
| 51 | + with mock.patch.object(sys, 'platform', 'win32'): |
| 52 | + assert shebang() == '#!/usr/bin/env python' |
| 53 | + |
| 54 | + |
| 55 | +def test_shebang_otherwise(): |
| 56 | + with mock.patch.object(sys, 'platform', 'posix'): |
| 57 | + assert 'default' not in shebang() |
| 58 | + |
| 59 | + |
| 60 | +def test_shebang_returns_default(): |
| 61 | + with mock.patch.object(sys, 'platform', 'posix'): |
| 62 | + with mock.patch.object( |
| 63 | + python, 'get_default_version', return_value='default', |
| 64 | + ): |
| 65 | + assert shebang() == '#!/usr/bin/env python' |
| 66 | + |
| 67 | + |
48 | 68 | def test_install_pre_commit(tempdir_factory, store): |
49 | 69 | path = git_dir(tempdir_factory) |
50 | 70 | runner = Runner(path, C.CONFIG_FILE) |
|
0 commit comments