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_string_conversion(self):
self.assertEqual(str(Mode.PIPENV), 'pipenv')
self.assertEqual(str(Mode.PYTHONPATH), 'pythonpath')
self.assertEqual(str(Mode.POETRY), 'poetry')
self.assertEqual(str(Mode.UNKNOWN), 'unknown')
self.assertEqual(str(Mode.UNDEFINED), 'undefined')
def test_get_effective_mode(self):
self.assertEqual(Mode.PIPENV.get_effective_mode(), Mode.PIPENV)
self.assertEqual(Mode.PYTHONPATH.get_effective_mode(), Mode.PYTHONPATH)
self.assertEqual(Mode.POETRY.get_effective_mode(), Mode.POETRY)
self.assertEqual(Mode.UNDEFINED.get_effective_mode(), Mode.PYTHONPATH)
self.assertEqual(Mode.UNKNOWN.get_effective_mode(), Mode.PYTHONPATH)
def read_mode(self) -> Mode:
lines = self.pre_commit_hook.split('\n')
if len(lines) < 1 or len(lines[0]) == 0:
return Mode.UNDEFINED
shebang = lines[0][2:]
if shebang == PYTHON3_SHEBANG:
return Mode.PYTHONPATH
if shebang == POETRY_SHEBANG:
return Mode.POETRY
if shebang == PIPENV_SHEBANG:
return Mode.PIPENV
return Mode.UNKNOWN
def get_effective_mode(self):
# pylint: disable=comparison-with-callable
if self.value == Mode.PIPENV.value:
return Mode.PIPENV
if self.value == Mode.POETRY.value:
return Mode.POETRY
return Mode.PYTHONPATH
def get_effective_mode(self):
# pylint: disable=comparison-with-callable
if self.value == Mode.PIPENV.value:
return Mode.PIPENV
if self.value == Mode.POETRY.value:
return Mode.POETRY
return Mode.PYTHONPATH