2017-01-05 17:09:29 +00:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
@pytest.mark.parametrize("text", ["lorem ipsum"])
|
2017-01-05 17:09:29 +00:00
|
|
|
def test_tokenizer_splits_single_space(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 2
|
|
|
|
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
@pytest.mark.parametrize("text", ["lorem ipsum"])
|
2017-01-05 17:09:29 +00:00
|
|
|
def test_tokenizer_splits_double_space(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 3
|
|
|
|
assert tokens[1].text == " "
|
|
|
|
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
@pytest.mark.parametrize("text", ["lorem ipsum "])
|
2020-07-27 18:18:48 +00:00
|
|
|
def test_tokenizer_handles_double_trailing_ws(tokenizer, text):
|
2017-01-05 17:09:29 +00:00
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert repr(tokens.text_with_ws) == repr(text)
|
|
|
|
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
@pytest.mark.parametrize("text", ["lorem\nipsum"])
|
2017-01-05 17:09:29 +00:00
|
|
|
def test_tokenizer_splits_newline(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 3
|
|
|
|
assert tokens[1].text == "\n"
|
|
|
|
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
@pytest.mark.parametrize("text", ["lorem \nipsum"])
|
2017-01-05 17:09:29 +00:00
|
|
|
def test_tokenizer_splits_newline_space(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 3
|
|
|
|
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
@pytest.mark.parametrize("text", ["lorem \nipsum"])
|
2017-01-05 17:09:29 +00:00
|
|
|
def test_tokenizer_splits_newline_double_space(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 3
|
|
|
|
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
@pytest.mark.parametrize("text", ["lorem \n ipsum"])
|
2017-01-05 17:09:29 +00:00
|
|
|
def test_tokenizer_splits_newline_space_wrap(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 3
|