Files
kefu/deploy/loading-performance-20260917/test_fixture_fix.py
T
2026-09-21 10:34:06 +08:00

23 lines
1.3 KiB
Python

from pathlib import Path
import shutil
root=Path('C:/wechat_rpa')
path=Path(__file__).with_name('test_protocol_probe_performance.py')
text=path.read_text(encoding='utf-8')
text=text.replace('import hashlib','import hashlib\nfrom contextlib import closing')
text=text.replace('with sqlite3.connect(','with closing(sqlite3.connect(').replace(') as connection:', ')) as connection:')
text=text.replace("('200','合成客户'+account,'',account))", "('200','合成客户'+account,'',account))\n connection.commit()")
text=text.replace("('S:'+account+'_200','合成会话','',''))", "('S:'+account+'_200','合成会话','',''))\n connection.commit()")
compile(text,str(path),'exec')
path.write_text(text,encoding='utf-8')
shutil.copy2(path,root/path.name)
path=root/'test_native_evidence.py'
text=path.read_text(encoding='utf-8')
old="mock.patch('wecom_native_sender.hashlib.sha256', return_value=SimpleNamespace(hexdigest=lambda:self.profile.sha256))"
assert text.count(old)==1
text=text.replace(old,"mock.patch('wecom_native_sender._client_file_digest', return_value=self.profile.sha256)")
backup=root/'backups/loading-performance-20260917'/path.name
assert not backup.exists()
shutil.copy2(path,backup)
path.write_text(text,encoding='utf-8')
print('Closed synthetic SQLite fixture connections and updated existing hash mock seam.')