2022-01-26 18:12:55 +01:00
|
|
|
from pathlib import Path
|
2023-11-24 11:52:55 +01:00
|
|
|
from unittest.mock import Mock
|
2020-05-04 18:00:07 +02:00
|
|
|
import pytest
|
2021-06-14 17:53:43 +02:00
|
|
|
|
2023-11-24 11:52:55 +01:00
|
|
|
from haystack.preview.testing.test_utils import set_all_seeds
|
2020-05-04 18:00:07 +02:00
|
|
|
|
2023-11-24 11:52:55 +01:00
|
|
|
set_all_seeds(0)
|
2022-01-25 20:36:28 +01:00
|
|
|
|
2022-08-12 09:27:56 +01:00
|
|
|
|
2023-11-24 11:52:55 +01:00
|
|
|
@pytest.fixture()
|
|
|
|
def mock_tokenizer():
|
2023-01-16 15:36:14 +01:00
|
|
|
"""
|
2023-11-24 11:52:55 +01:00
|
|
|
Tokenizes the string by splitting on spaces.
|
2023-01-16 15:36:14 +01:00
|
|
|
"""
|
2023-11-24 11:52:55 +01:00
|
|
|
tokenizer = Mock()
|
|
|
|
tokenizer.encode = lambda text: text.split()
|
|
|
|
tokenizer.decode = lambda tokens: " ".join(tokens)
|
|
|
|
return tokenizer
|
2023-06-13 14:52:24 +02:00
|
|
|
|
|
|
|
|
2023-11-24 11:52:55 +01:00
|
|
|
@pytest.fixture()
|
|
|
|
def test_files_path():
|
|
|
|
return Path(__file__).parent / "test_files"
|