"""Tests for script utils.""" import pytest from scripts import utils @pytest.mark.parametrize('text, expected', [ (None, False), ('yes', True), ('True', True), ('1', True), ('NO', False), ('fAlSe', False), ('0', False), ]) def test_parse_boolean(text, expected): """Test parsing text as boolean.""" result = utils.parse_boolean(text) assert result == expected @pytest.mark.parametrize('text', [ 'test', 'maybe', '123', ]) def test_parse_boolean_error(text): """Test parsing text as boolean with text which can't be parsed.""" with pytest.raises(ValueError) as error: utils.parse_boolean(text) assert str(error.value) == f'Unable to parse "{text}" as boolean'