aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2017-03-26 03:07:56 +0700
committerSergey M․ <dstftw@gmail.com>2017-03-26 03:07:56 +0700
commit41c5e60dd57c0df10f4aa05dee95af2bbc1dc8dd (patch)
treea82ad23d83642339e399067c71af8991d70594ea
parentd212c93d16bbb6aeb8645f1dbb15a78f3d9414a8 (diff)
[test_utils] Fix expand_path tests
-rw-r--r--test/test_utils.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index 8c50b46e8..b9a02666d 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -218,11 +218,16 @@ class TestUtil(unittest.TestCase):
self.assertEqual(sanitize_path('./../abc'), '..\\abc')
def test_expand_path(self):
+ def env(var):
+ return '%{0}%'.format(var) if sys.platform == 'win32' else '${0}'.format(var)
+
compat_setenv('YOUTUBE-DL-EXPATH-PATH', 'expanded')
- self.assertEqual(expand_path('%YOUTUBE-DL-EXPATH-PATH%'), 'expanded')
- self.assertEqual(expand_path('%HOMEPATH%'), compat_getenv('HOMEPATH'))
+ self.assertEqual(expand_path(env('YOUTUBE-DL-EXPATH-PATH')), 'expanded')
+ self.assertEqual(expand_path(env('HOMEPATH')), compat_getenv('HOMEPATH'))
self.assertEqual(expand_path('~'), compat_getenv('HOME'))
- self.assertEqual(expand_path('~/%YOUTUBE-DL-EXPATH-PATH%'), '%s/expanded' % compat_getenv('HOME'))
+ self.assertEqual(
+ expand_path('~/%s' % env('YOUTUBE-DL-EXPATH-PATH')),
+ '%s/expanded' % compat_getenv('HOME'))
def test_prepend_extension(self):
self.assertEqual(prepend_extension('abc.ext', 'temp'), 'abc.temp.ext')