intpirt 150 в TOC, хранящемся в файле, показывает (пока открывается с помощью кодирования VS utf8) < /p>
Код: Выделить всё
[1, '02 Leyenda de símbolos ', 135]
< /code>
Если я прочитал TOC в терминале PowerShell (Windows 10); Я получаю < /p>
>>> import pymupdf
>>> doc = pymupdf.open('data/RISE CARBON SL-LT 2025 BLUEPAPER EN-ES-FR-IT-DE 14.02.25.pdf')
>>> toc = doc.get_toc(simple=True)
>>> toc[150]
[1, '02 Leyenda de símbolos ', 135]
< /code>
Но если я запускаю тест, сравнивая TOC, полученный во время выполнения, и, один сохраненный < /p>
def test_raw_toc():
filepath = data_filepath(PDFNAME)
toc = pformat(get_pdf_toc(filepath), indent=4)
test_file = pathlib.Path("tests/toc_raw.txt")
with open(test_file) as f:
toc_raw = f.read() # Python 3.x
assert toc == toc_raw
< /code>
Показывает следующая ошибка: < /p>
> assert toc == toc_raw
E assert "[ [1, '01 ...onen ', 651]]" == "[ [1, '01 ...onen ', 651]]"
E
E Skipping 7366 identical leading characters in diff, use -v to show
E - yenda de sÃmbolos ', 135],
E ? ^^
E + yenda de símbolos ', 135],
E ? ^
E - [1, '03 GarantÃa Orbea ', 136],...
E
E ...Full output truncated (1383 lines hidden), use '-vv' to show
tests\test_toc_from_pdf.py:15: AssertionError
Любая причина, почему эта ошибка? Почему вывод Pytest, показывающий Sãmbolo ; В то время как интерпретатор показывает símbolos ?
[1] PDF (~ 100 МБ) можно найти здесь.
Подробнее здесь: https://stackoverflow.com/questions/795 ... ith-pytest