Skip to content

Commit

Permalink
Python3: fix test_url by skipping iso8859-1 variant
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Jan 6, 2018
1 parent a3f23f6 commit 4535a5c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
9 changes: 9 additions & 0 deletions tests/__init__.py
Expand Up @@ -117,6 +117,15 @@ def has_msgfmt ():
need_msgfmt = _need_func(has_msgfmt, "msgfmt")


@memoized
def has_python2 ():
"""Test if this is a Python 2."""
return sys.version_info < (3, 0)


need_python2 = _need_func(has_python2, "Python 2")


@memoized
def has_posix ():
"""Test if this is a POSIX system."""
Expand Down
22 changes: 18 additions & 4 deletions tests/test_url.py
Expand Up @@ -17,7 +17,7 @@
"""
Test url routines.
"""
from . import need_network, need_posix, need_windows
from . import need_network, need_posix, need_python2, need_windows
import unittest
import os
import re
Expand Down Expand Up @@ -131,13 +131,27 @@ def test_norm_quote (self):
url = "http://example.com/?u=http://example2.com?b="
nurl = "http://example.com/?u=http://example2.com?b="
self.urlnormtest(url, nurl)
url = "http://localhost:8001/?quoted=ü"
nurl = "http://localhost:8001/?quoted=%FC"
self.urlnormtest(url, nurl, encoding="iso-8859-1")
url = "http://host/?a=b/c+d="
nurl = "http://host/?a=b/c%20d%3D"
self.urlnormtest(url, nurl)

@need_python2
def test_norm_quote_iso (self):
"""
Check quoting URL with iso characters
This does not work on Python 3,
because urllib.parse.quote works only with UTF8
"""
url = "http://localhost:8001/?quoted=ü"
nurl = "http://localhost:8001/?quoted=%FC"
self.urlnormtest(url, nurl, encoding="iso-8859-1")

def test_norm_quote_utf (self):
""" Check quoting the same URL with utf characters """
url = u"http://localhost:8001/?quoted=ü"
nurl = "http://localhost:8001/?quoted=%C3%BC"
self.urlnormtest(url, nurl, encoding="utf8")

def test_norm_case_sensitivity (self):
# Test url norm case sensitivity.
# Always provide the URI scheme in lowercase characters.
Expand Down

0 comments on commit 4535a5c

Please sign in to comment.