File: test_tokenizer.py

package info (click to toggle)
python-cutadapt 4.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,992 kB
  • sloc: python: 9,695; ansic: 177; makefile: 159
file content (22 lines) | stat: -rw-r--r-- 633 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest

from cutadapt.tokenizer import tokenize_braces, StringToken, BraceToken, TokenizeError


def test_tokenize_braces():
    tokenize = tokenize_braces
    assert list(tokenize("")) == []
    assert list(tokenize("text")) == [StringToken("text")]
    assert list(tokenize("before {variable} after")) == [
        StringToken("before "),
        BraceToken("variable"),
        StringToken(" after"),
    ]


def test_tokenize_unexpected_braces():
    with pytest.raises(TokenizeError):
        list(tokenize_braces("abc {def{ghi}"))

    with pytest.raises(TokenizeError):
        list(tokenize_braces("abc {def} gh} i"))