diff -r dd6ad9af49f4 django/db/__init__.py
a
|
b
|
|
39 | 39 | def reset_queries(**kwargs): |
40 | 40 | for conn in connections.all(): |
41 | 41 | conn.queries = [] |
42 | | signals.request_started.connect(reset_queries) |
| 42 | if settings.DEBUG: |
| 43 | signals.request_started.connect(reset_queries) |
43 | 44 | |
44 | 45 | # Register an event that rolls back the connections |
45 | 46 | # when a Django request has an exception. |
diff -r dd6ad9af49f4 django/test/testcases.py
a
|
b
|
|
220 | 220 | self.old_debug_cursor = self.connection.use_debug_cursor |
221 | 221 | self.connection.use_debug_cursor = True |
222 | 222 | self.starting_queries = len(self.connection.queries) |
223 | | request_started.disconnect(reset_queries) |
| 223 | if settings.DEBUG: |
| 224 | request_started.disconnect(reset_queries) |
224 | 225 | return self |
225 | 226 | |
226 | 227 | def __exit__(self, exc_type, exc_value, traceback): |
227 | 228 | self.connection.use_debug_cursor = self.old_debug_cursor |
228 | | request_started.connect(reset_queries) |
| 229 | if settings.DEBUG: |
| 230 | request_started.connect(reset_queries) |
229 | 231 | if exc_type is not None: |
230 | 232 | return |
231 | 233 | |