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_use_default_template(self):
template = PreCommitTemplate()
self.assertEqual(
template.render(mode=Mode.PYTHONPATH), DEFAULT_TEMPLATE
)
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 render(self, *, mode: Mode) -> str:
mode = mode.get_effective_mode()
if mode == Mode.PIPENV:
params = dict(SHEBANG=PIPENV_SHEBANG)
elif mode == Mode.POETRY:
params = dict(SHEBANG=POETRY_SHEBANG)
else:
params = dict(SHEBANG=PYTHON3_SHEBANG)
return self._template.safe_substitute(params)
def render(self, *, mode: Mode) -> str:
mode = mode.get_effective_mode()
if mode == Mode.PIPENV:
params = dict(SHEBANG=PIPENV_SHEBANG)
elif mode == Mode.POETRY:
params = dict(SHEBANG=POETRY_SHEBANG)
else:
params = dict(SHEBANG=PYTHON3_SHEBANG)
return self._template.safe_substitute(params)