Skip to content

Commit

Permalink
Add repr to UrlMappingMatchInfo #217
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jan 31, 2015
1 parent f38f6c3 commit d90395b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Unreleased (XX-XX-XXXX)

- Add repr for web.Application

- Add repr to UrlMappingMatchInfo #217

0.14.4 (01-29-2015)
-------------------

Expand Down
3 changes: 3 additions & 0 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,9 @@ def handler(self):
def route(self):
return self._route

def __repr__(self):
return "<MatchInfo {}: {}>".format(super().__repr__(), self._route)


class Route(metaclass=abc.ABCMeta):

Expand Down
15 changes: 15 additions & 0 deletions tests/test_urldispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,21 @@ def test_route_dynamic_with_regex_spec_and_trailing_slash(self):
url = route.url(parts={'num': '123'})
self.assertEqual('/get/123/', url)

def test_regular_match_info(self):

@asyncio.coroutine
def go():
handler = self.make_handler()
self.router.add_route('GET', '/get/{name}', handler)

req = self.make_request('GET', '/get/john')
match_info = yield from self.router.resolve(req)
self.maxDiff = None
self.assertRegex(repr(match_info),
"<MatchInfo {'name': 'john'}: <DynamicRoute.+>>")

self.loop.run_until_complete(go())

def test_not_found_repr(self):

@asyncio.coroutine
Expand Down

0 comments on commit d90395b

Please sign in to comment.