Commit 5e07c68f authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

Anleitung ergänzt

parent ac39dda7
......@@ -183,6 +183,8 @@ class StringView: # collections.abc.Sized
start, stop = fast_real_indices(index.start, index.stop, self._len)
return StringView(self._text, self._begin + start, self._begin + stop)
except AttributeError:
if index >= self._len:
raise IndexError("StringView index %i out of range 0 - %i" % (index, self._len))
return StringView(self._text, self._begin + index, self._begin + index + 1)
# return self._text[self._begin + index] # leads to type errors
......
This diff is collapsed.
......@@ -92,7 +92,7 @@ add_module_names = False
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster' # 'sphinx_rtd_theme'
html_theme = 'sphinx_rtd_theme' # 'alabaster' # 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
......
......@@ -145,10 +145,18 @@ class TestStringView:
s = StringView('"22"')
assert s.strip('"') == '22'
def text_split(self):
def test_split(self):
s = StringView(' 1,2,3,4,5 ', 1, -1)
assert s.split(',') == ['1', '2', '3', '4', '5']
def test_index_error(self):
s = StringView('0123456789')
try:
s[25]
assert False, "IndexError expected!"
except IndexError:
pass
class TestTextBuffer:
test_text = "\n".join([
......
......@@ -71,6 +71,13 @@ class TestParseSxpression:
assert str(tree) == "LIUTPR. leg. 21 ..."
assert tree.attr['unterbedeutungstiefe'] == '0'
def test_parse_s_expression_malformed(self):
try:
s = parse_sxpr('(A (B 1) (C (D (E 2) (F 3)) (G 4) (H (I 5) (J 6)) (K 7)')
assert False, "ValueError exptected!"
except ValueError:
pass
def test_endlessloop_error(self):
tree = parse_sxpr(r'(LINEFEED "\\")')
assert tree
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment