File: test_util_string_filter.py

package info (click to toggle)
quodlibet 4.6.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,016 kB
  • sloc: python: 85,817; sh: 385; xml: 110; makefile: 91
file content (35 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download | duplicates (3)
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
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

from tests import TestCase

from quodlibet.util.string.filter import remove_diacritics, remove_punctuation

SOME_FRENCH = "goût d'œufs à Noël"


class TRemoveDiacritics(TestCase):

    def test_empty(self):
        assert remove_diacritics("") == ""
        assert remove_diacritics(" \t\n") == " \t\n"

    def test_harder(self):
        assert remove_diacritics("abc '123' ?!") == "abc '123' ?!"
        assert remove_diacritics(SOME_FRENCH) == "gout d'œufs a Noel"


class TRemovePunctuation(TestCase):

    def test_empty(self):
        assert remove_punctuation("") == ""
        assert remove_punctuation(" \t\n") == " \t\n"

    def test_harder(self):
        assert remove_punctuation("\"abc\" '123' ?!") == "abc 123 "
        assert remove_punctuation(SOME_FRENCH) == "goût dœufs à Noël"

    def test_unicode(self):
        assert remove_punctuation("†one⁋two\u2003three") == "onetwo\u2003three"