File: test_TOMLEscape.py

package info (click to toggle)
python-briefcase 0.3.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,596 kB
  • sloc: python: 62,519; makefile: 60
file content (35 lines) | stat: -rw-r--r-- 816 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
23
24
25
26
27
28
29
30
31
32
33
34
35
from unittest.mock import MagicMock

import pytest

from briefcase.integrations.cookiecutter import TOMLEscape


@pytest.mark.parametrize(
    "value, expected",
    [
        # Single digit minor
        ("Hello World", "Hello World"),
        ('Hello " World', 'Hello \\" World'),
        ("Hello \\ World", "Hello \\\\ World"),
    ],
)
def test_escape_toml(value, expected):
    env = MagicMock()
    env.filters = {}
    TOMLEscape(env)
    assert env.filters["escape_toml"](value) == expected


@pytest.mark.parametrize(
    "value, expected",
    [
        ("helloworld", "helloworld"),
        ("helloworldı", '"helloworldı"'),
    ],
)
def test_escape_non_ascii(value, expected):
    env = MagicMock()
    env.filters = {}
    TOMLEscape(env)
    assert env.filters["escape_non_ascii"](value) == expected