2021.10.3 #35

Merged
edraft merged 31 commits from 2021.10.3 into 2021.10 2021-08-02 14:36:46 +02:00
3 changed files with 12 additions and 3 deletions
Showing only changes of commit 82a9e3a23a - Show all commits

View File

@ -1,6 +1,6 @@
from typing import Optional from typing import Optional
from cpl_query.exceptions import ArgumentNoneException, ExceptionArgument from cpl_query.exceptions import ArgumentNoneException, ExceptionArgument, IndexOutOfRangeException
from cpl_query.extension.iterable_abc import IterableABC from cpl_query.extension.iterable_abc import IterableABC
@ -9,7 +9,7 @@ def first_query(_list: IterableABC) -> any:
raise ArgumentNoneException(ExceptionArgument.list) raise ArgumentNoneException(ExceptionArgument.list)
if len(_list) == 0: if len(_list) == 0:
raise Exception('Index out of range') raise IndexOutOfRangeException()
return _list[0] return _list[0]

View File

@ -14,7 +14,13 @@ class ExceptionArgument(Enum):
class ArgumentNoneException(Exception): class ArgumentNoneException(Exception):
def __init__(self, arg: ExceptionArgument): def __init__(self, arg: ExceptionArgument):
Exception.__init__(self, f'Argument {arg} is None') Exception.__init__(self, f'argument {arg} is None')
class IndexOutOfRangeException(Exception):
def __init__(self):
Exception.__init__(self, f'List index out of range')
class InvalidTypeException(Exception): class InvalidTypeException(Exception):

View File

@ -100,6 +100,9 @@ class QueryTest(unittest.TestCase):
self.assertEqual(self._tests[index], self._tests.element_at_or_default(index)) self.assertEqual(self._tests[index], self._tests.element_at_or_default(index))
self.assertIsNone(self._tests.element_at_or_default(len(self._tests))) self.assertIsNone(self._tests.element_at_or_default(len(self._tests)))
test = [1, 2, 3]
t = test[100]
def test_first(self): def test_first(self):
results = [] results = []
for user in self._tests: for user in self._tests: