Adive01 commited on
Commit
907098b
·
verified ·
1 Parent(s): 13a295c

Upload tests/test_common.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. tests/test_common.py +21 -0
tests/test_common.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ from mlplo.common import normalize_text, count_words, resolve_model_reference
3
+
4
+ def test_normalize_text():
5
+ assert normalize_text(None) == ""
6
+ assert normalize_text(123) == "123"
7
+ assert normalize_text(["a", "b"]) == "['a', 'b']"
8
+ assert normalize_text(" hello \n \t world ") == "hello world"
9
+ assert normalize_text("a\u00a0b") == "a b"
10
+
11
+ def test_count_words():
12
+ assert count_words(None) == 0
13
+ assert count_words(123) == 0
14
+ assert count_words("") == 0
15
+ assert count_words("hello world") == 2
16
+
17
+ def test_resolve_model_reference():
18
+ assert resolve_model_reference("my_model") == "my_model"
19
+ assert resolve_model_reference("", fallback="fallback") == "fallback"
20
+ with pytest.raises(ValueError):
21
+ resolve_model_reference(None, None)