Repository: yt-dlp/yt-dlp
File: test/test_utils.py (Python)

Code before:
        self.assertEqual(escape_rfc3986('foo bar'), 'foo%20bar')
        self.assertEqual(escape_rfc3986('foo%20bar'), 'foo%20bar')

    def test_normalize_url(self):
        self.assertEqual(
            normalize_url('http://wowza.imust.org/srv/vod/telemb/new/UPLOAD/UPLOAD/20224_IncendieHavré_FD.mp4'),
            'http://wowza.imust.org/srv/vod/telemb/new/UPLOAD/UPLOAD/20224_IncendieHavre%CC%81_FD.mp4'
        )
        self.assertEqual(
            normalize_url('http://www.ardmediathek.de/tv/Sturm-der-Liebe/Folge-2036-Zu-Mann-und-Frau-erklärt/Das-Erste/Video?documentId=22673108&bcastId=5290'),
            'http://www.ardmediathek.de/tv/Sturm-der-Liebe/Folge-2036-Zu-Mann-und-Frau-erkl%C3%A4rt/Das-Erste/Video?documentId=22673108&bcastId=5290'
        )
        self.assertEqual(
            normalize_url('http://тест.рф/фрагмент'),
            'http://xn--e1aybc.xn--p1ai/%D1%84%D1%80%D0%B0%D0%B3%D0%BC%D0%B5%D0%BD%D1%82'
        )
        self.assertEqual(
            normalize_url('http://тест.рф/абв?абв=абв#абв'),
            'http://xn--e1aybc.xn--p1ai/%D0%B0%D0%B1%D0%B2?%D0%B0%D0%B1%D0%B2=%D0%B0%D0%B1%D0%B2#%D0%B0%D0%B1%D0%B2'
        )
        self.assertEqual(normalize_url('http://vimeo.com/56015672#at=0'), 'http://vimeo.com/56015672#at=0')

        self.assertEqual(normalize_url('http://www.example.com/../a/b/../c/./d.html'), 'http://www.example.com/a/c/d.html')

    def test_remove_dot_segments(self):
        # XXX: we really should use pytest with parametrize here for my sanity
        self.assertEqual(remove_dot_segments('/a/b/c/./../../g'), '/a/g')
        self.assertEqual(remove_dot_segments('mid/content=5/../6'), 'mid/6')
        self.assertEqual(remove_dot_segments('/ad/../cd'), '/cd')
        self.assertEqual(remove_dot_segments('/ad/../cd/'), '/cd/')
        self.assertEqual(remove_dot_segments('/..'), '/')
        self.assertEqual(remove_dot_segments('/./'), '/')
        self.assertEqual(remove_dot_segments('/./a'), '/a')
        self.assertEqual(remove_dot_segments('/abc/./.././d/././e/.././f/./../../ghi'), '/ghi')
        self.assertEqual(remove_dot_segments('/'), '/')
        self.assertEqual(remove_dot_segments('/t'), '/t')
        self.assertEqual(remove_dot_segments('t'), 't')
        self.assertEqual(remove_dot_segments(''), '')
        self.assertEqual(remove_dot_segments('/../a/b/c'), '/a/b/c')
        self.assertEqual(remove_dot_segments('../a'), 'a')
        self.assertEqual(remove_dot_segments('./a'), 'a')
        self.assertEqual(remove_dot_segments('.'), '')
        self.assertEqual(remove_dot_segments('////'), '////')

    def test_js_to_json_vars_strings(self):
        self.assertDictEqual(
            json.loads(js_to_json(
                '''{
                    'null': a,
                    'nullStr': b,
                    'true': c,

Review comment (suggestion):
```suggestion
```
This'd have to be done for the whole file

Code after:
        self.assertEqual(escape_rfc3986('foo bar'), 'foo%20bar')
        self.assertEqual(escape_rfc3986('foo%20bar'), 'foo%20bar')

    def test_normalize_url(self):
        self.assertEqual(
            normalize_url('http://wowza.imust.org/srv/vod/telemb/new/UPLOAD/UPLOAD/20224_IncendieHavré_FD.mp4'),
            'http://wowza.imust.org/srv/vod/telemb/new/UPLOAD/UPLOAD/20224_IncendieHavre%CC%81_FD.mp4'
        )
        self.assertEqual(
            normalize_url('http://www.ardmediathek.de/tv/Sturm-der-Liebe/Folge-2036-Zu-Mann-und-Frau-erklärt/Das-Erste/Video?documentId=22673108&bcastId=5290'),
            'http://www.ardmediathek.de/tv/Sturm-der-Liebe/Folge-2036-Zu-Mann-und-Frau-erkl%C3%A4rt/Das-Erste/Video?documentId=22673108&bcastId=5290'
        )
        self.assertEqual(
            normalize_url('http://тест.рф/фрагмент'),
            'http://xn--e1aybc.xn--p1ai/%D1%84%D1%80%D0%B0%D0%B3%D0%BC%D0%B5%D0%BD%D1%82'
        )
        self.assertEqual(
            normalize_url('http://тест.рф/абв?абв=абв#абв'),
            'http://xn--e1aybc.xn--p1ai/%D0%B0%D0%B1%D0%B2?%D0%B0%D0%B1%D0%B2=%D0%B0%D0%B1%D0%B2#%D0%B0%D0%B1%D0%B2'
        )
        self.assertEqual(normalize_url('http://vimeo.com/56015672#at=0'), 'http://vimeo.com/56015672#at=0')

        self.assertEqual(normalize_url('http://www.example.com/../a/b/../c/./d.html'), 'http://www.example.com/a/c/d.html')

    def test_remove_dot_segments(self):
        self.assertEqual(remove_dot_segments('/a/b/c/./../../g'), '/a/g')
        self.assertEqual(remove_dot_segments('mid/content=5/../6'), 'mid/6')
        self.assertEqual(remove_dot_segments('/ad/../cd'), '/cd')
        self.assertEqual(remove_dot_segments('/ad/../cd/'), '/cd/')
        self.assertEqual(remove_dot_segments('/..'), '/')
        self.assertEqual(remove_dot_segments('/./'), '/')
        self.assertEqual(remove_dot_segments('/./a'), '/a')
        self.assertEqual(remove_dot_segments('/abc/./.././d/././e/.././f/./../../ghi'), '/ghi')
        self.assertEqual(remove_dot_segments('/'), '/')
        self.assertEqual(remove_dot_segments('/t'), '/t')
        self.assertEqual(remove_dot_segments('t'), 't')
        self.assertEqual(remove_dot_segments(''), '')
        self.assertEqual(remove_dot_segments('/../a/b/c'), '/a/b/c')
        self.assertEqual(remove_dot_segments('../a'), 'a')
        self.assertEqual(remove_dot_segments('./a'), 'a')
        self.assertEqual(remove_dot_segments('.'), '')
        self.assertEqual(remove_dot_segments('////'), '////')

    def test_js_to_json_vars_strings(self):
        self.assertDictEqual(
            json.loads(js_to_json(
                '''{
                    'null': a,
                    'nullStr': b,
                    'true': c,
                    'trueStr': d,