python - Route testing with Tornado -
i'm new tornado, , working on project involves rather complex routing. in of other frameworks i've used i've been able isolate routing testing, without spinning server or doing terribly complex. i'd prefer use pytest testing framework, i'm not sure matters.
is there way to, say, create project's instance of tornado.web.application
, , pass arbitrary paths , assert requesthandler
invoked based on path?
no, not possible test in tornado via public interface (as of tornado version 4.3).
it's straightforward avoid spinning server, although requires nontrivial amount of code: interface between httpserver , application well-defined , documented. trickier part other side: there no supported way determine handler invoked before handler is invoked.
i recommend testing routing via end-to-end tests reason. store url route list before passing tornado, , tests against - internal logic of "take first regex match" pretty easy replicate.
Comments
Post a Comment