From a68d89a4f351f8df2bfceeac77540b23e29827be Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 24 Oct 2017 12:05:25 +0200 Subject: [PATCH] Add failing test for bug #1375 -- no out-of-bounds error for token.nbor() --- spacy/tests/regression/test_issue1375.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 spacy/tests/regression/test_issue1375.py diff --git a/spacy/tests/regression/test_issue1375.py b/spacy/tests/regression/test_issue1375.py new file mode 100644 index 000000000..72070758d --- /dev/null +++ b/spacy/tests/regression/test_issue1375.py @@ -0,0 +1,16 @@ +from __future__ import unicode_literals +import pytest +from ...vocab import Vocab +from ...tokens.doc import Doc + +@pytest.mark.xfail +def test_issue1375(): + '''Test that token.nbor() raises IndexError for out-of-bounds access.''' + doc = Doc(Vocab(), words=['0', '1', '2']) + with pytest.raises(IndexError): + assert doc[0].nbor(-1) + assert doc[1].nbor(-1).text == '0' + with pytest.raises(IndexError): + assert doc[2].nbor(1) + assert doc[1].nbor(1).text == '2' +