# Path: src/japronto/router/route.py
# class Route:
#     def __init__(self, pattern, handler, methods):
#         self.pattern = pattern
#         self.handler = handler
#         self.methods = methods
#         self.segments = parse(pattern)
#         self.placeholder_cnt = \
#             sum(1 for s in self.segments if s[0] == 'placeholder')
# 
#     def __repr__(self):
#         return '<Route {}, {} {}>'.format(
#             self.pattern, self.methods, hex(id(self)))
# 
#     def describe(self):
#         return self.pattern + (' ' if self.methods else '') + \
#             ' '.join(self.methods)
# 
#     def __eq__(self, other):
#         return self.pattern == other.pattern and self.methods == other.methods
# 
# Path: src/japronto/router/matcher.py
# class Matcher:
#     def __init__(self, routes):
#         self._routes = routes
# 
#     def match_request(self, request):
#         for route in self._routes:
#             match_dict = {}
#             rest = request.path
# 
#             value = True
#             for typ, data in route.segments:
#                 if typ == 'exact':
#                     if not rest.startswith(data):
#                         break
# 
#                     rest = rest[len(data):]
#                 elif typ == 'placeholder':
#                     value, slash, rest = rest.partition('/')
#                     if not value:
#                         break
#                     match_dict[data] = value
#                     rest = slash + rest
#                 else:
#                     assert 0, 'Unknown type'
# 
#             if rest:
#                 continue
# 
#             if not value:
#                 continue
# 
#             if len(match_dict) != route.placeholder_cnt:
#                 continue
# 
#             if route.methods and request.method not in route.methods:
#                 continue
# 
#             return route, match_dict


from functools import partial
from . import Route
from .matcher import Matcher
from .cmatcher import Matcher as CMatcher
import pytest
        return Route.__new__(cls)

    def __init__(self, pattern, methods):
        super().__init__(pattern, lambda x: None, methods=methods)

    def __del__(self):
        type(self).cnt -= 1
        print('del')


def route_from_str(value):
    pattern, *methods = value.split()
    if methods:
        methods = methods[0].split(',')

    return TracingRoute(pattern, methods=methods)


def parametrize_make_matcher():
    def make(cls):
        routes = [route_from_str(r) for r in [
            '/',
            '/test GET',
            '/hi/{there} POST,DELETE',
            '/{oh}/{dear} PATCH',
            '/lets PATCH'
        ]]

        return cls(routes)


# Path: src/japronto/router/route.py
# class Route:
#     def __init__(self, pattern, handler, methods):
#         self.pattern = pattern
#         self.handler = handler
#         self.methods = methods
#         self.segments = parse(pattern)
#         self.placeholder_cnt = \
#             sum(1 for s in self.segments if s[0] == 'placeholder')
# 
#     def __repr__(self):
#         return '<Route {}, {} {}>'.format(
#             self.pattern, self.methods, hex(id(self)))
# 
#     def describe(self):
#         return self.pattern + (' ' if self.methods else '') + \
#             ' '.join(self.methods)
# 
#     def __eq__(self, other):
#         return self.pattern == other.pattern and self.methods == other.methods
# 
# Path: src/japronto/router/matcher.py
# class Matcher:
#     def __init__(self, routes):
#         self._routes = routes
# 
#     def match_request(self, request):
#         for route in self._routes:
#             match_dict = {}
#             rest = request.path
# 
#             value = True
#             for typ, data in route.segments:
#                 if typ == 'exact':
#                     if not rest.startswith(data):
#                         break
# 
#                     rest = rest[len(data):]
#                 elif typ == 'placeholder':
#                     value, slash, rest = rest.partition('/')
#                     if not value:
#                         break
#                     match_dict[data] = value
#                     rest = slash + rest
#                 else:
#                     assert 0, 'Unknown type'
# 
#             if rest:
#                 continue
# 
#             if not value:
#                 continue
# 
#             if len(match_dict) != route.placeholder_cnt:
#                 continue
# 
#             if route.methods and request.method not in route.methods:
#                 continue
# 
#             return route, match_dict


# Path: src/japronto/router/test_matcher.py
from functools import partial
from . import Route
from .matcher import Matcher
from .cmatcher import Matcher as CMatcher
import pytest

        return Route.__new__(cls)

    def __init__(self, pattern, methods):
        super().__init__(pattern, lambda x: None, methods=methods)

    def __del__(self):
        type(self).cnt -= 1
        print('del')


def route_from_str(value):
    pattern, *methods = value.split()
    if methods:
        methods = methods[0].split(',')

    return TracingRoute(pattern, methods=methods)


def parametrize_make_matcher():
    def make(cls):
        routes = [route_from_str(r) for r in [
            '/',
            '/test GET',
            '/hi/{there} POST,DELETE',
            '/{oh}/{dear} PATCH',
            '/lets PATCH'
        ]]

        return cls(routes)


    make_matcher = partial(make, Matcher)