File: test_utils.py

package info (click to toggle)
python-bleach 3.1.2-0%2Bdeb10u2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,320 kB
  • sloc: python: 13,477; makefile: 130; sh: 47
file content (44 lines) | stat: -rw-r--r-- 1,117 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
36
37
38
39
40
41
42
43
44
from collections import OrderedDict

from bleach.utils import alphabetize_attributes


class TestAlphabeticalAttributes:
    def test_empty_cases(self):
        assert alphabetize_attributes(None) is None

        assert alphabetize_attributes({}) == {}

    def test_ordering(self):
        assert (
            alphabetize_attributes({
                (None, 'a'): 1,
                (None, 'b'): 2
            }) ==
            OrderedDict([
                ((None, 'a'), 1),
                ((None, 'b'), 2)
            ])
        )
        assert (
            alphabetize_attributes({
                (None, 'b'): 1,
                (None, 'a'): 2}
            ) ==
            OrderedDict([
                ((None, 'a'), 2),
                ((None, 'b'), 1)
            ])
        )

    def test_different_namespaces(self):
        assert (
            alphabetize_attributes({
                ('xlink', 'href'): 'abc',
                (None, 'alt'): '123'
            }) ==
            OrderedDict([
                ((None, 'alt'), '123'),
                (('xlink', 'href'), 'abc')
            ])
        )