diff options
author | Jesús <heckyel@hyperbola.info> | 2022-06-27 01:25:17 +0800 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2022-06-27 01:25:17 +0800 |
commit | 16e8548f6a720a78679e417a20a300db2036bf6c (patch) | |
tree | b1247bca3417ce882e4a4d80213f41c20113c1a4 /test/test_utils.py | |
parent | 4bbf329feb5a820ac21269fa426c95ca14d7af25 (diff) | |
parent | e08f72e6759fb6b1102521f0bdb9457038ef7c06 (diff) | |
download | hypervideo-pre-16e8548f6a720a78679e417a20a300db2036bf6c.tar.lz hypervideo-pre-16e8548f6a720a78679e417a20a300db2036bf6c.tar.xz hypervideo-pre-16e8548f6a720a78679e417a20a300db2036bf6c.zip |
updated from upstream | 27/06/2022 at 01:25
Diffstat (limited to 'test/test_utils.py')
-rw-r--r-- | test/test_utils.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/test/test_utils.py b/test/test_utils.py index 184c39cff..8024a8e7c 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 + # Allow direct execution -import contextlib import os import sys import unittest @@ -8,19 +8,16 @@ import unittest sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -# Various small unit tests +import contextlib import io import itertools import json import xml.etree.ElementTree from yt_dlp.compat import ( - compat_chr, compat_etree_fromstring, - compat_getenv, compat_HTMLParseError, compat_os_name, - compat_setenv, ) from yt_dlp.utils import ( Config, @@ -266,20 +263,20 @@ class TestUtil(unittest.TestCase): def env(var): return f'%{var}%' if sys.platform == 'win32' else f'${var}' - compat_setenv('yt_dlp_EXPATH_PATH', 'expanded') + os.environ['yt_dlp_EXPATH_PATH'] = 'expanded' self.assertEqual(expand_path(env('yt_dlp_EXPATH_PATH')), 'expanded') old_home = os.environ.get('HOME') test_str = R'C:\Documents and Settings\тест\Application Data' try: - compat_setenv('HOME', test_str) - self.assertEqual(expand_path(env('HOME')), compat_getenv('HOME')) - self.assertEqual(expand_path('~'), compat_getenv('HOME')) + os.environ['HOME'] = test_str + self.assertEqual(expand_path(env('HOME')), os.getenv('HOME')) + self.assertEqual(expand_path('~'), os.getenv('HOME')) self.assertEqual( expand_path('~/%s' % env('yt_dlp_EXPATH_PATH')), - '%s/expanded' % compat_getenv('HOME')) + '%s/expanded' % os.getenv('HOME')) finally: - compat_setenv('HOME', old_home or '') + os.environ['HOME'] = old_home or '' def test_prepend_extension(self): self.assertEqual(prepend_extension('abc.ext', 'temp'), 'abc.temp.ext') @@ -1128,7 +1125,7 @@ class TestUtil(unittest.TestCase): self.assertEqual(extract_attributes('<e x="décomposé">'), {'x': 'décompose\u0301'}) # "Narrow" Python builds don't support unicode code points outside BMP. try: - compat_chr(0x10000) + chr(0x10000) supports_outside_bmp = True except ValueError: supports_outside_bmp = False |