def parse_search_argument(self, filter_type, value): if filter_type in ('any', 'all'): try: return [self.subtype.from_argument(elem) for elem in split_with_escape(value, '|', '\\')] except ValueError, e: self._illegal_argument(value, str(e))
def parse_search_argument(self, filter_type, value): """Parse search argument of type filter_type""" if filter_type == 'in': try: return [self.from_argument(elem) for elem in split_with_escape(value, '|', '\\')] except ValueError, e: self._illegal_argument(value, str(e))
def test_split_unknown_esc(self): gen = split_with_escape(r'abc\a', '|') self.assertRaises(ValueError, list, gen)
def test_split_no_last_esc(self): gen = split_with_escape('abc\\', '|') self.assertRaises(ValueError, list, gen)
def test_split_esc_single_char(self): gen = split_with_escape('abc', '|', 'escape') self.assertRaises(ValueError, list, gen)
def test_split_empty(self): result = list(split_with_escape(r'abc||def|', '|')) self.assertEquals(['abc', '', 'def', ''], result)
def test_split_with_esc_esc(self): result = list(split_with_escape(r'abc|def\\|qwe', '|')) self.assertEquals(['abc', 'def\\', 'qwe'], result)
def test_split_simple(self): result = list(split_with_escape('abc|def|qwe', '|')) self.assertEquals(['abc', 'def', 'qwe'], result)
def test_split_single(self): result = list(split_with_escape('abc', '|')) self.assertEquals(['abc'], result)
def test_split_no_last_esc(self): gen = split_with_escape("abc\\", "|") self.assertRaises(ValueError, list, gen)
def test_split_unknown_esc(self): gen = split_with_escape(r"abc\a", "|") self.assertRaises(ValueError, list, gen)
def test_split_esc_single_char(self): gen = split_with_escape("abc", "|", "escape") self.assertRaises(ValueError, list, gen)
def test_split_empty(self): result = list(split_with_escape(r"abc||def|", "|")) self.assertEquals(["abc", "", "def", ""], result)
def test_split_with_esc_esc(self): result = list(split_with_escape(r"abc|def\\|qwe", "|")) self.assertEquals(["abc", "def\\", "qwe"], result)
def test_split_simple(self): result = list(split_with_escape("abc|def|qwe", "|")) self.assertEquals(["abc", "def", "qwe"], result)
def test_split_single(self): result = list(split_with_escape("abc", "|")) self.assertEquals(["abc"], result)