2017-01-05 20:09:29 +03:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
@pytest.mark.parametrize("text", ["lorem ipsum"])
|
2017-01-05 20:09:29 +03:00
|
|
|
def test_tokenizer_splits_single_space(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 2
|
|
|
|
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
@pytest.mark.parametrize("text", ["lorem ipsum"])
|
2017-01-05 20:09:29 +03:00
|
|
|
def test_tokenizer_splits_double_space(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 3
|
|
|
|
assert tokens[1].text == " "
|
|
|
|
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
@pytest.mark.parametrize("text", ["lorem ipsum "])
|
2017-01-05 20:09:29 +03:00
|
|
|
def test_tokenizer_handles_double_trainling_ws(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert repr(tokens.text_with_ws) == repr(text)
|
|
|
|
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
@pytest.mark.parametrize("text", ["lorem\nipsum"])
|
2017-01-05 20:09:29 +03:00
|
|
|
def test_tokenizer_splits_newline(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 3
|
|
|
|
assert tokens[1].text == "\n"
|
|
|
|
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
@pytest.mark.parametrize("text", ["lorem \nipsum"])
|
2017-01-05 20:09:29 +03:00
|
|
|
def test_tokenizer_splits_newline_space(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 3
|
|
|
|
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
@pytest.mark.parametrize("text", ["lorem \nipsum"])
|
2017-01-05 20:09:29 +03:00
|
|
|
def test_tokenizer_splits_newline_double_space(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 3
|
|
|
|
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
@pytest.mark.parametrize("text", ["lorem \n ipsum"])
|
2017-01-05 20:09:29 +03:00
|
|
|
def test_tokenizer_splits_newline_space_wrap(tokenizer, text):
|
|
|
|
tokens = tokenizer(text)
|
|
|
|
assert len(tokens) == 3
|