| from __future__ import absolute_import |
| from __future__ import unicode_literals |
| from pre_commit_hooks.check_executables_have_shebangs import main |
| @pytest.mark.parametrize( |
| b'#!/bin/bash\nhello world\n', |
| b'#!/usr/bin/env python3.6', |
| def test_has_shebang(content, tmpdir): |
| path = tmpdir.join('path') |
| path.write(content, 'wb') |
| assert main((path.strpath,)) == 0 |
| @pytest.mark.parametrize( |
| def test_bad_shebang(content, tmpdir, capsys): |
| path = tmpdir.join('path') |
| path.write(content, 'wb') |
| assert main((path.strpath,)) == 1 |
| _, stderr = capsys.readouterr() |
| assert stderr.startswith('{}: marked executable but'.format(path.strpath)) |