Opened 7 years ago
Last modified 7 years ago
#12713 closed enhancement
Update of callbacks dict in RequestDispatcher.dispatch makes it difficult to write test case — at Initial Version
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.2.1 |
Component: | web frontend | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
For example I've written some test case like browser:trachacksplugin/trunk/trachacks/tests/web_ui.py@15127:109#L104, but when I try to use MockRequest
the tests don't pass because the callbacks are overwritten: tags/trac-1.2/trac/web/main.py@:195-206#L184.
I can make the tests work with the following change:
-
trac/web/main.py
diff --git a/trac/web/main.py b/trac/web/main.py index b0680ab5b..261debb27 100644
a b class RequestDispatcher(Component): 192 192 chrome = Chrome(self.env) 193 193 194 194 # Setup request callbacks for lazily-evaluated properties 195 req.callbacks.update({195 default_callbacks = { 196 196 'authname': self.authenticate, 197 197 'chrome': chrome.prepare_request, 198 198 'form_token': self._get_form_token, … … class RequestDispatcher(Component): 203 203 'tz': self._get_timezone, 204 204 'use_xsendfile': self._get_use_xsendfile, 205 205 'xsendfile_header': self._get_xsendfile_header, 206 }) 206 } 207 for key, value in default_callbacks.iteritems(): 208 req.callbacks.setdefault(key, value) 207 209 208 210 try: 209 211 # Select the component that should handle the request
Does anyone foresee any negative side effects?
Note:
See TracTickets
for help on using tickets.