File: test_utils_encoding.py

package info (click to toggle)
streamlink 1.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,588 kB
  • sloc: python: 31,121; makefile: 141; sh: 93
file content (24 lines) | stat: -rw-r--r-- 883 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# encoding=utf8
import unittest

from streamlink.compat import is_py3, is_py2
from streamlink.utils.encoding import maybe_decode, maybe_encode


class TestUtilsEncoding(unittest.TestCase):

    @unittest.skipUnless(is_py2, "only applicable in Python 2")
    def test_maybe_encode_py2(self):
        self.assertEqual(maybe_encode(u"test \u07f7"), "test \xdf\xb7")

    @unittest.skipUnless(is_py2, "only applicable in Python 2")
    def test_maybe_decode_py2(self):
        self.assertEqual(maybe_decode("test \xdf\xb7"), u"test \u07f7")

    @unittest.skipUnless(is_py3, "only applicable in Python 3")
    def test_maybe_encode_py3(self):
        self.assertEqual(maybe_encode(u"test \u07f7"), u"test \u07f7")

    @unittest.skipUnless(is_py3, "only applicable in Python 3")
    def test_maybe_decode_py3(self):
        self.assertEqual(maybe_decode(u"test \u07f7"), u"test \u07f7")