File size: 906 Bytes
2d4c842
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import glob
import unittest

from custom_tokenizer_adapters import load_custom_tokenizer


ROOT = "/tmp/tokenizer-extract.GBtvQ0/repo"
PATTERNS = ["Arek/**/*.json", "KasiaMP/wyniki/tokenizer z boilerplate.json", "KasiaMP/wyniki/wyniki*.json", "ola/*.json", "patryk/*.json"]
SAMPLES = ["Zażółć gęślą jaźń.", "Łódź 2026 — € 😀\n\tKoniec"]


class CustomAdaptersTest(unittest.TestCase):
    def test_every_custom_artifact_roundtrips(self):
        paths = sorted({p for pattern in PATTERNS for p in glob.glob(f"{ROOT}/{pattern}", recursive=True)})
        self.assertEqual(len(paths), 25)
        for path in paths:
            with self.subTest(path=path):
                tokenizer = load_custom_tokenizer(path)
                for sample in SAMPLES:
                    self.assertEqual(tokenizer.decode(tokenizer.encode(sample)), sample)


if __name__ == "__main__":
    unittest.main()