summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>2016-02-18 23:28:25 +0100
committerSviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>2016-02-18 23:28:25 +0100
commitfd2606b0a4fc5d9d9cf80237671e19f3d6515daa (patch)
treedbd5af86c062b6a122d3598e2aca21730a866c22
parentbafc1536f2a354cdb7526a3a40f580885e4dc484 (diff)
parentae9b86a43a7fabcadcb28dfc5f8eff559b32ec59 (diff)
downloadroutes-fd2606b0a4fc5d9d9cf80237671e19f3d6515daa.tar.gz
Merge pull request #1 from bbangert/master
Update from upstream
-rw-r--r--.gitignore1
-rw-r--r--.travis.yml11
-rw-r--r--CHANGELOG.rst4
-rw-r--r--routes/mapper.py14
-rw-r--r--setup.py3
-rw-r--r--tests/test_functional/test_recognition.py4
-rw-r--r--tox.ini17
7 files changed, 40 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index 17db388..3f925d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,4 @@ html_coverage
.hgignore
.idea
*.iml
+.tox/
diff --git a/.travis.yml b/.travis.yml
index e698e42..65a02f6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,9 +4,12 @@ python:
- "2.7"
- "3.3"
- "3.4"
+ - "3.5"
+ - "nightly"
- "pypy"
- "pypy3"
-install:
- - python setup.py develop
- - pip install webob webtest coverage
-script: nosetests
+matrix:
+ allow_failures:
+ - python: "nightly"
+install: pip install tox-travis
+script: tox
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 7433724..5f2d915 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -3,10 +3,10 @@ Routes Changelog
Release 2.3 (**dev**)
=====================
-
+* Fix matching of an empty string route, which led to exception in earlier
+ versions. PR #58. Patch by Sviatoslav Sydorenko.
* Add support for the ``requirements`` option when using
mapper.resource to create routes. PR #57. Patch by Sean Dague.
-
* Concatenation fix when using submappers with path prefixes. Multiple
submappers combined the path prefix inside the controller argument in
non-obvious ways. The controller argument will now be properly carried
diff --git a/routes/mapper.py b/routes/mapper.py
index 382c01d..06f09f2 100644
--- a/routes/mapper.py
+++ b/routes/mapper.py
@@ -713,10 +713,10 @@ class Mapper(SubMapperParent):
resultdict = m.match('/joe/sixpack')
"""
- if not url and not environ:
+ if url is None and not environ:
raise RoutesException('URL or environ must be provided')
- if not url:
+ if url is None:
url = environ['PATH_INFO']
result = self._match(url, environ)
@@ -737,10 +737,10 @@ class Mapper(SubMapperParent):
resultdict, route_obj = m.match('/joe/sixpack')
"""
- if not url and not environ:
+ if url is None and not environ:
raise RoutesException('URL or environ must be provided')
- if not url:
+ if url is None:
url = environ['PATH_INFO']
result = self._match(url, environ)
if self.debug:
@@ -789,7 +789,11 @@ class Mapper(SubMapperParent):
six.text_type(kargs).encode('utf8')
if self.urlcache is not None:
- cache_key_script_name = '%s:%s' % (script_name, cache_key)
+ if six.PY3:
+ cache_key_script_name = b':'.join((script_name.encode('utf-8'),
+ cache_key))
+ else:
+ cache_key_script_name = '%s:%s' % (script_name, cache_key)
# Check the url cache to see if it exists, use it if it does
val = self.urlcache.get(cache_key_script_name, self)
diff --git a/setup.py b/setup.py
index 742c645..4c64f6e 100644
--- a/setup.py
+++ b/setup.py
@@ -41,7 +41,8 @@ setup(name="Routes",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
- "Programming Language :: Python :: 3.4"
+ "Programming Language :: Python :: 3.4",
+ "Programming Language :: Python :: 3.5"
],
keywords='routes webob dispatch',
author="Ben Bangert",
diff --git a/tests/test_functional/test_recognition.py b/tests/test_functional/test_recognition.py
index 5e50a60..03fe6a7 100644
--- a/tests/test_functional/test_recognition.py
+++ b/tests/test_functional/test_recognition.py
@@ -913,7 +913,7 @@ class TestRecognition(unittest.TestCase):
eq_({'controller':'content','action':'index','id':None}, m.match('/content'))
eq_({'controller':'content','action':'view','id':'4'}, m.match('/'))
def call_func():
- m.match('')
+ m.match(None)
assert_raises(RoutesException, call_func)
def test_home_noargs(self):
@@ -926,7 +926,7 @@ class TestRecognition(unittest.TestCase):
eq_(None, m.match('/content'))
eq_({}, m.match('/'))
def call_func():
- m.match('')
+ m.match(None)
assert_raises(RoutesException, call_func)
def test_dot_format_args(self):
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..2c2419f
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,17 @@
+[tox]
+envlist = py26,py27,py33,py34,pypy,pypy3
+
+[testenv]
+deps=
+ coverage
+ nose
+ webob
+ webtest
+commands=
+ python -bb -m nose tests {posargs}
+
+[testenv:py26]
+# Ony Python 2.6, python -m test doesn't work. Anyway, python -bb is only
+# interested on Python 3.
+commands=
+ nosetests tests {posargs}