mirror of
https://github.com/explosion/spaCy.git
synced 2025-06-05 13:43:24 +03:00
Add failing test for bug #1375 -- no out-of-bounds error for token.nbor()
This commit is contained in:
parent
ccd2ab1a62
commit
a68d89a4f3
16
spacy/tests/regression/test_issue1375.py
Normal file
16
spacy/tests/regression/test_issue1375.py
Normal file
|
@ -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'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user