okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
3616148bb
main
1"""#3202: a Windows 11 with Russian localization (cp1251 / cp866 code pages): a Cyrillic folder name must reach the engine, 2the run config and the tools unchanged.""" 3import json 4import os 5import subprocess 6import sys 7import tempfile 8import unittest 9from pathlib import Path 10 11ROOT = Path (__file__ ).resolve ().parents [1 ] 12sys .path .insert (0 ,str (ROOT )) 13 14WORD = "" .join (chr (c )for c in (0x414 ,0x43e ,0x43a ,0x443 ,0x43c ,0x435 ,0x43d ,0x442 ,0x44b ))# "Документы" 15 16 17class CyrillicFolder (unittest .TestCase ): 18def setUp (self ): 19self .tmp = tempfile .TemporaryDirectory (prefix = WORD + "-" ) 20self .dir = Path (self .tmp .name ) 21 22def tearDown (self ): 23self .tmp .cleanup () 24 25def test_run_config_in_a_cyrillic_folder_is_found_and_read (self ): 26from strata_control import discovery 27cfg = self .dir / "strata-q2_0.json" 28cfg .write_text (json .dumps ({"exe" :"x" ,"args" : ["--native" ,str (self .dir / "m.gguf" )]},ensure_ascii = False ),encoding = "utf-8" ) 29place = discovery .places (explicit = self .dir )[0 ] 30self .assertEqual (place .configs ,1 ) 31back = json .loads (discovery .config_files (self .dir )[0 ].read_text (encoding = "utf-8" )) 32self .assertIn (WORD ,back ["args" ][1 ]) 33 34def test_a_child_python_gets_the_path_as_an_argument_and_prints_it_back (self ): 35# the server starts the engine through serve.server.popen; the child reads the argument and its own file listing 36from serve import server 37 (self .dir / "m.gguf" ).write_bytes (b"x" ) 38env = dict (os .environ ,PYTHONUTF8 = "1" ,PYTHONIOENCODING = "utf-8" ) 39code = "import sys, os; print(sys.argv[1]); print(os.path.exists(os.path.join(sys.argv[1], 'm.gguf')))" 40proc = server .popen ("test child" , [sys .executable ,"-c" ,code ,str (self .dir )],role = "test" , 41stdout = subprocess .PIPE ,env = env ) 42out = proc .stdout .read ().decode ("utf-8" ).splitlines () 43proc .wait (timeout = 30 ) 44self .assertEqual (out [0 ],str (self .dir )) 45self .assertEqual (out [1 ],"True" ) 46 47def test_windows_launchers_set_utf8_mode (self ): 48for name in ("START-HERE.bat" ,"bin/strata.cmd" ,"bin/strata.ps1" ): 49text = (ROOT / name ).read_text (encoding = "utf-8" ) 50self .assertIn ("PYTHONUTF8" ,text ,name ) 51 52 53if __name__ == "__main__" : 54unittest .main ()