Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_should_render_mode_poetry(self):
path = FakeTemplatePath("$SHEBANG")
template = PreCommitTemplate(path)
self.assertEqual(
template.render(mode=Mode.POETRY),
"/usr/bin/env -S poetry run python3",
)
def test_should_render_mode_undefined(self):
path = FakeTemplatePath("$SHEBANG")
template = PreCommitTemplate(path)
self.assertEqual(
template.render(mode=Mode.UNDEFINED), "/usr/bin/env python3"
)
def test_should_render_mode_unknown(self):
path = FakeTemplatePath("$SHEBANG")
template = PreCommitTemplate(path)
self.assertEqual(
template.render(mode=Mode.UNDEFINED), "/usr/bin/env python3"
)
def test_should_render_mode_pipenv(self):
path = FakeTemplatePath("$SHEBANG")
template = PreCommitTemplate(path)
self.assertEqual(
template.render(mode=Mode.PIPENV),
"/usr/bin/env -S pipenv run python3",
)
def test_should_use_default_template(self):
template = PreCommitTemplate()
self.assertEqual(
template.render(mode=Mode.PYTHONPATH), DEFAULT_TEMPLATE
)
def write(self, *, mode: Mode):
template = PreCommitTemplate()
pre_commit_hook = template.render(mode=mode)
self.pre_commit_hook_path.write_text(pre_commit_hook)
self.pre_commit_hook_path.chmod(0o775)
self._pre_commit_hook = None
def get_autohooks_pre_commit_hook(mode: Mode) -> str:
template = PreCommitTemplate()
return template.render(mode=mode)