diff options
author | Ben Bangert <ben@groovie.org> | 2009-01-02 15:06:48 -0800 |
---|---|---|
committer | Ben Bangert <ben@groovie.org> | 2009-01-02 15:06:48 -0800 |
commit | 1f8aa360cf0d82e335dfc36366722c4cb2e99157 (patch) | |
tree | a40b73ab71d641639e3f97259a6224933cc6a31b /tests/test_functional | |
parent | b07e3e588b5634cecb1034acb7cdda28f457ae65 (diff) | |
download | routes-1f8aa360cf0d82e335dfc36366722c4cb2e99157.tar.gz |
* Bugfix for unicode encoding problems with non-minimized Route generation.
Spotted by Wichert Akkerman.
--HG--
branch : trunk
Diffstat (limited to 'tests/test_functional')
-rw-r--r-- | tests/test_functional/test_nonminimization.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_functional/test_nonminimization.py b/tests/test_functional/test_nonminimization.py index fdd3483..b18a901 100644 --- a/tests/test_functional/test_nonminimization.py +++ b/tests/test_functional/test_nonminimization.py @@ -1,7 +1,9 @@ """Test non-minimization recognition""" +import urllib from nose.tools import eq_ +from routes import url_for from routes.mapper import Mapper @@ -111,3 +113,32 @@ def test_regexp_syntax(): eq_(None, m.generate(controller='content', id=4)) eq_('/content/index/43', m.generate(controller='content', id=43)) eq_('/content/view/31', m.generate(controller='content', action='view', id=31)) + +def test_unicode(): + hoge = u'\u30c6\u30b9\u30c8' # the word test in Japanese + hoge_enc = urllib.quote(hoge.encode('utf-8')) + m = Mapper() + m.minimization = False + m.connect(':hoge') + eq_("/%s" % hoge_enc, m.generate(hoge=hoge)) + assert isinstance(m.generate(hoge=hoge), str) + +def test_unicode_static(): + hoge = u'\u30c6\u30b9\u30c8' # the word test in Japanese + hoge_enc = urllib.quote(hoge.encode('utf-8')) + m = Mapper() + m.minimization = False + m.connect('google-jp', 'http://www.google.co.jp/search', _static=True) + m.create_regs(['messages']) + eq_("http://www.google.co.jp/search?q=" + hoge_enc, + url_for('google-jp', q=hoge)) + assert isinstance(url_for('google-jp', q=hoge), str) + +def test_other_special_chars(): + m = Mapper() + m.minimization = False + m.connect('/:year/:(slug).:(format),:(locale)', locale='en', format='html') + m.create_regs(['content']) + + assert '/2007/test.xml,ja' == m.generate(year=2007, slug='test', format='xml', locale='ja') + assert None == m.generate(year=2007, format='html') |