Skip to content

Commit

Permalink
add tests to test_laser_tokenizer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
NIXBLACK11 authored Nov 19, 2023
1 parent b7d3d35 commit 3f4c553
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions laser_encoders/test_laser_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import numpy as np
import pytest
import warnings

from laser_encoders import (
LaserEncoderPipeline,
Expand Down Expand Up @@ -285,3 +286,18 @@ def test_encoder_non_normalization(tmp_path: Path, test_readme_params: dict):
norm = np.linalg.norm(non_normalized_embeddings[0])

assert not np.isclose(norm, 1)


def test_optional_lang_with_laser2(tmp_path: Path):
with pytest.warns(UserWarning, match="The 'lang' parameter is optional when using 'laser2'. It will be ignored."):
encoder = LaserEncoderPipeline(lang="en", laser="laser2", model_dir=tmp_path)


def test_required_lang_with_laser3(tmp_path: Path):
with pytest.raises(ValueError, match="For 'laser3', the 'lang' parameter is required."):
encoder = LaserEncoderPipeline(laser="laser3", model_dir=tmp_path)


def test_missing_lang_and_laser(tmp_path: Path):
with pytest.raises(ValueError, match="Either 'laser' or 'lang' should be provided."):
encoder = LaserEncoderPipeline(model_dir=tmp_path)

0 comments on commit 3f4c553

Please sign in to comment.