- «Заменить всё» в редакторе заменяет все совпадения, а не первые 5000 с сообщением об успехе; замена с \1 работает, когда в шаблоне есть (?=...); - при включённом «Акцент из Windows» программа красится в нынешний акцент системы при запуске, а не в тот, что сохранился при включении; - после «вперёд» по журналу экранов новый экран сбрасывает направление, и недоступная страница не оставляет журнал на несуществующей записи; - «Стоп» в очереди подбора читается как «Отменено», а не «Ошибка подбора»; - второй запуск в ту же секунду больше не стирает начало лога первого; - «С прошлой проверки» сравнивает прогоны при одинаковом состоянии Zapret. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
|
|
class LogsRuntimeHelpersTests(unittest.TestCase):
|
|
def test_errors_text_height_checks_document_empty_without_reading_widget_text(self) -> None:
|
|
from log.ui.runtime_helpers import compute_errors_text_height
|
|
|
|
class _Size:
|
|
def height(self) -> int:
|
|
return 80
|
|
|
|
class _Document:
|
|
def isEmpty(self) -> bool: # noqa: N802
|
|
return False
|
|
|
|
def size(self) -> _Size:
|
|
return _Size()
|
|
|
|
class _TextEdit:
|
|
def toPlainText(self) -> str: # noqa: N802
|
|
raise AssertionError("GUI errors text should not be read to compute height")
|
|
|
|
def document(self) -> _Document:
|
|
return _Document()
|
|
|
|
def frameWidth(self) -> int: # noqa: N802
|
|
return 2
|
|
|
|
height = compute_errors_text_height(
|
|
text_edit=_TextEdit(),
|
|
min_height=20,
|
|
max_height=200,
|
|
)
|
|
|
|
self.assertEqual(height, 100)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|
|
|
|
|
|
class UniqueLogFilenameTests(unittest.TestCase):
|
|
def test_second_launch_in_the_same_second_gets_its_own_file(self) -> None:
|
|
import os
|
|
import tempfile
|
|
|
|
from log.log import unique_log_filename
|
|
|
|
with tempfile.TemporaryDirectory() as folder:
|
|
name = "zapret_log_2026-11-01_12-00-05.txt"
|
|
self.assertEqual(unique_log_filename(folder, name), name)
|
|
open(os.path.join(folder, name), "w").close()
|
|
|
|
second = unique_log_filename(folder, name)
|
|
|
|
self.assertNotEqual(second, name)
|
|
self.assertTrue(second.startswith("zapret_log_2026-11-01_12-00-05_") and second.endswith(".txt"))
|
|
open(os.path.join(folder, second), "w").close()
|
|
self.assertNotIn(unique_log_filename(folder, name), (name, second))
|