/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_urlutils.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-02-14 03:16:54 UTC
  • mfrom: (7479.2.3 no-more-python2)
  • Revision ID: breezy.the.bot@gmail.com-20200214031654-bp1xtv2jr9nmhto3
Drop python2 support.

Merged from https://code.launchpad.net/~jelmer/brz/no-more-python2/+merge/378694

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from ..errors import (
24
24
    PathNotChild,
25
25
    )
26
 
from ..sixish import (
27
 
    text_type,
28
 
    PY3,
29
 
    )
30
26
from . import features, TestCaseInTempDir, TestCase, TestSkipped
31
27
 
32
28
 
129
125
        eq('http://host/~bob%2525-._',
130
126
           normalize_url(u'http://host/%7Ebob%2525%2D%2E%5F'))
131
127
 
132
 
        if not PY3:
133
 
            # On Python 2, normalize verifies URLs when they are not unicode
134
 
            # (indicating they did not come from the user)
135
 
            self.assertRaises(urlutils.InvalidURL, normalize_url,
136
 
                              b'http://host/\xb5')
137
 
            self.assertRaises(urlutils.InvalidURL,
138
 
                              normalize_url, b'http://host/ ')
139
 
 
140
128
    def test_url_scheme_re(self):
141
129
        # Test paths that may be URLs
142
130
        def test_one(url, scheme_and_path):
449
437
 
450
438
        self.assertEqual(
451
439
            'file://HOST/path/to/r%C3%A4ksm%C3%B6rg%C3%A5s', result)
452
 
        self.assertFalse(isinstance(result, text_type))
 
440
        self.assertFalse(isinstance(result, str))
453
441
 
454
442
    def test_win32_local_path_from_url(self):
455
443
        from_url = urlutils._win32_local_path_from_url
678
666
        # Test that URLs are converted to nice unicode strings for display
679
667
        def test(expected, url, encoding='utf-8'):
680
668
            disp_url = urlutils.unescape_for_display(url, encoding=encoding)
681
 
            self.assertIsInstance(disp_url, text_type)
 
669
            self.assertIsInstance(disp_url, str)
682
670
            self.assertEqual(expected, disp_url)
683
671
 
684
672
        test('http://foo', 'http://foo')
727
715
        self.assertEqual('%', urlutils.unescape('%25'))
728
716
        self.assertEqual(u'\xe5', urlutils.unescape('%C3%A5'))
729
717
 
730
 
        if not PY3:
731
 
            self.assertRaises(urlutils.InvalidURL, urlutils.unescape, u'\xe5')
732
718
        self.assertRaises((TypeError, urlutils.InvalidURL),
733
719
                          urlutils.unescape, b'\xe5')
734
 
        if not PY3:
735
 
            self.assertRaises(urlutils.InvalidURL, urlutils.unescape, '%E5')
736
 
        else:
737
 
            self.assertEqual('\xe5', urlutils.unescape('%C3%A5'))
 
720
        self.assertEqual('\xe5', urlutils.unescape('%C3%A5'))
738
721
 
739
722
    def test_escape_unescape(self):
740
723
        self.assertEqual(u'\xe5', urlutils.unescape(urlutils.escape(u'\xe5')))
1140
1123
 
1141
1124
    def test_unquote(self):
1142
1125
        self.assertEqual('%', urlutils.unquote('%25'))
1143
 
        if PY3:
1144
 
            self.assertEqual('\xe5', urlutils.unquote('%C3%A5'))
1145
 
        else:
1146
 
            self.assertEqual('\xc3\xa5', urlutils.unquote('%C3%A5'))
 
1126
        self.assertEqual('\xe5', urlutils.unquote('%C3%A5'))
1147
1127
        self.assertEqual(u"\xe5", urlutils.unquote(u'\xe5'))
1148
1128
 
1149
1129
    def test_unquote_to_bytes(self):