コード例 #1
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_optional_profiling_with_show_request_starts_profiling(self):
     # If profiling is allowed and a request with the "show" marker
     # URL segment is made, profiling starts.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/++profile++show/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEquals(set(profile._profilers.actions), set(('show', )))
コード例 #2
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_optional_profiling_with_wrong_request_helps(self):
     # If profiling is allowed and a request with the marker URL segment
     # is made incorrectly, profiling does not start and help is an action.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/++profile++/'))
     self.assertIs(getattr(profile._profilers, 'profiler', None), None)
     self.assertEqual(set(profile._profilers.actions), set(('help', )))
コード例 #3
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_optional_profiling_with_show_request_starts_profiling(self):
     # If profiling is allowed and a request with the "show" marker
     # URL segment is made, profiling starts.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/++profile++show/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEqual(set(profile._profilers.actions), set(('show', )))
コード例 #4
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_optional_profiling_with_wrong_request_helps(self):
     # If profiling is allowed and a request with the marker URL segment
     # is made incorrectly, profiling does not start and help is an action.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/++profile++/'))
     self.assertIs(getattr(profile._profilers, 'profiler', None), None)
     self.assertEquals(set(profile._profilers.actions), set(('help', )))
コード例 #5
0
 def test_optional_profiling_with_pstats_request_starts_profiling(self):
     # If profiling is allowed and a request with the "pstats" marker,
     # profiling starts with the pstats profiler.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/++profile++pstats/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEquals(set(profile._profilers.actions), set(('pstats', )))
コード例 #6
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_optional_profiling_with_log_request_starts_profiling(self):
     # If profiling is allowed and a request with the "log" marker URL
     # segment is made, profiling starts as a callgrind profile request.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/++profile++log/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEqual(
         set(profile._profilers.actions), set(('callgrind', )))
コード例 #7
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_forced_profiling_registers_action(self):
     # profile_all_requests should register as a callgrind action.
     self.pushProfilingConfig(
         profiling_allowed='True', profile_all_requests='True')
     profile.start_request(self._get_start_event('/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEquals(
         set(profile._profilers.actions), set(('callgrind', )))
コード例 #8
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_forced_profiling_registers_action(self):
     # profile_all_requests should register as a callgrind action.
     self.pushProfilingConfig(
         profiling_allowed='True', profile_all_requests='True')
     profile.start_request(self._get_start_event('/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEqual(
         set(profile._profilers.actions), set(('callgrind', )))
コード例 #9
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_optional_profiling_with_log_request_starts_profiling(self):
     # If profiling is allowed and a request with the "log" marker URL
     # segment is made, profiling starts as a callgrind profile request.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/++profile++log/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEquals(
         set(profile._profilers.actions), set(('callgrind', )))
コード例 #10
0
 def test_optional_profiling_without_marked_request_has_no_profile(self):
     # Even if profiling is allowed, it does not happen with a normal
     # request.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/'))
     self.assertFalse(profile._profilers.profiling)
     self.assertIs(getattr(profile._profilers, 'profiler', None), None)
     self.assertIs(getattr(profile._profilers, 'actions', None), None)
コード例 #11
0
 def test_optional_profiling_with_combined_request_starts_profiling(self):
     # If profiling is allowed and a request with the "callgrind" and
     # "show" marker URL segment is made, profiling starts.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(
         self._get_start_event('/++profile++callgrind&show/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEquals(set(profile._profilers.actions),
                       set(('callgrind', 'show')))
コード例 #12
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_config_stops_profiling(self):
     """The ``profiling_allowed`` configuration should disable all
     profiling, even if it is requested"""
     self.pushProfilingConfig(
         profiling_allowed='False', profile_all_requests='True',
         memory_profile_log='.')
     profile.start_request(self._get_start_event(
         '/++profile++show&callgrind'))
     self.assertCleanProfilerState('config was ignored')
コード例 #13
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_config_stops_profiling(self):
     """The ``profiling_allowed`` configuration should disable all
     profiling, even if it is requested"""
     self.pushProfilingConfig(
         profiling_allowed='False', profile_all_requests='True',
         memory_profile_log='.')
     profile.start_request(self._get_start_event(
         '/++profile++show&callgrind'))
     self.assertCleanProfilerState('config was ignored')
コード例 #14
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_combo_memory_and_profile_start(self):
     self.pushProfilingConfig(
         profiling_allowed='True', memory_profile_log='.')
     profile.start_request(self._get_start_event('/++profile++show/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     actions = profile._profilers.actions
     self.assertEqual(set(actions), set(['memory_profile_start', 'show']))
     self.assertIsInstance(actions['memory_profile_start'], tuple)
     self.assertEqual(len(actions['memory_profile_start']), 2)
コード例 #15
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_memory_profile_start(self):
     self.pushProfilingConfig(
         profiling_allowed='True', memory_profile_log='.')
     profile.start_request(self._get_start_event('/'))
     self.assertIs(getattr(profile._profilers, 'profiler', None), None)
     actions = profile._profilers.actions
     self.assertEqual(set(actions), set(['memory_profile_start']))
     self.assertIsInstance(actions['memory_profile_start'], tuple)
     self.assertEqual(len(actions['memory_profile_start']), 2)
コード例 #16
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_forced_profiling_with_wrong_request_helps(self):
     # If profiling is forced and a request with the marker URL segment
     # is made incorrectly, profiling starts and help is an action.
     self.pushProfilingConfig(
         profiling_allowed='True', profile_all_requests='True')
     profile.start_request(self._get_start_event('/++profile++/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEqual(
         set(profile._profilers.actions), set(('help', 'callgrind')))
コード例 #17
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_optional_profiling_without_marked_request_has_no_profile(self):
     # Even if profiling is allowed, it does not happen with a normal
     # request.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/'))
     self.assertFalse(profile._profilers.profiling)
     self.assertIs(getattr(profile._profilers, 'profiler', None), None)
     self.assertIs(
         getattr(profile._profilers, 'actions', None), None)
コード例 #18
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_sqltrace_filtered_start(self):
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event(
         '/++profile++sqltrace:includes bugsubscription/'))
     self.assertIs(getattr(profile._profilers, 'profiler', None), None)
     self.assertEqual(set(profile._profilers.actions), set(('sql', )))
     data = profile._profilers.actions['sql']
     self.assertTrue(data['condition']('SELECT BUGSUBSCRIPTION FROM FOO'))
     self.assertEqual([], da.stop_sql_logging())
コード例 #19
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_sqltrace_filtered_start(self):
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event(
         '/++profile++sqltrace:includes bugsubscription/'))
     self.assertIs(getattr(profile._profilers, 'profiler', None), None)
     self.assertEquals(set(profile._profilers.actions), set(('sql', )))
     data = profile._profilers.actions['sql']
     self.assertTrue(data['condition']('SELECT BUGSUBSCRIPTION FROM FOO'))
     self.assertEqual([], da.stop_sql_logging())
コード例 #20
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_combo_memory_and_profile_start(self):
     self.pushProfilingConfig(
         profiling_allowed='True', memory_profile_log='.')
     profile.start_request(self._get_start_event('/++profile++show/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     actions = profile._profilers.actions
     self.assertEqual(set(actions), set(['memory_profile_start', 'show']))
     self.assertIsInstance(actions['memory_profile_start'], tuple)
     self.assertEqual(len(actions['memory_profile_start']), 2)
コード例 #21
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_forced_profiling_with_wrong_request_helps(self):
     # If profiling is forced and a request with the marker URL segment
     # is made incorrectly, profiling starts and help is an action.
     self.pushProfilingConfig(
         profiling_allowed='True', profile_all_requests='True')
     profile.start_request(self._get_start_event('/++profile++/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEquals(
         set(profile._profilers.actions), set(('help', 'callgrind')))
コード例 #22
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_memory_profile_start(self):
     self.pushProfilingConfig(
         profiling_allowed='True', memory_profile_log='.')
     profile.start_request(self._get_start_event('/'))
     self.assertIs(getattr(profile._profilers, 'profiler', None), None)
     actions = profile._profilers.actions
     self.assertEqual(set(actions), set(['memory_profile_start']))
     self.assertIsInstance(actions['memory_profile_start'], tuple)
     self.assertEqual(len(actions['memory_profile_start']), 2)
コード例 #23
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_optional_profiling_with_pstats_request_starts_profiling(self):
     # If profiling is allowed and a request with the "pstats" marker,
     # profiling starts with the pstats profiler.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(
         self._get_start_event('/++profile++pstats/'))
     self.assertIsInstance(profile._profilers.profiler,
                           profile.Profiler)
     self.assertEquals(set(profile._profilers.actions), set(('pstats',)))
コード例 #24
0
 def test_optional_profiling_with_callgrind_pstats(self):
     # If profiling is allowed and a request with both the "pstats" and
     # "callgrind" markers, profiling starts with the bzr/callgrind
     # profiler.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(
         self._get_start_event('/++profile++pstats&callgrind/'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEquals(set(profile._profilers.actions),
                       set(('pstats', 'callgrind')))
コード例 #25
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_optional_profiling_with_callgrind_pstats(self):
     # If profiling is allowed and a request with both the "pstats" and
     # "callgrind" markers, profiling starts with the bzr/callgrind
     # profiler.
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(
         self._get_start_event('/++profile++pstats&callgrind/'))
     self.assertIsInstance(profile._profilers.profiler,
                           profile.Profiler)
     self.assertEquals(
         set(profile._profilers.actions), set(('pstats', 'callgrind')))
コード例 #26
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_optional_profiling_with_reversed_request_starts_profiling(self):
     # If profiling is allowed and a request with the "show" and the
     # "callgrind" marker URL segment is made, profiling starts.
     self.pushProfilingConfig(profiling_allowed='True')
     # The fact that this is reversed from the previous request is the only
     # difference from the previous test.  Also, it doesn't have a
     # trailing slash. :-P
     profile.start_request(
         self._get_start_event('/++profile++show&callgrind'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEquals(
         set(profile._profilers.actions), set(('callgrind', 'show')))
コード例 #27
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_optional_profiling_with_reversed_request_starts_profiling(self):
     # If profiling is allowed and a request with the "show" and the
     # "callgrind" marker URL segment is made, profiling starts.
     self.pushProfilingConfig(profiling_allowed='True')
     # The fact that this is reversed from the previous request is the only
     # difference from the previous test.  Also, it doesn't have a
     # trailing slash. :-P
     profile.start_request(
         self._get_start_event('/++profile++show&callgrind'))
     self.assertIsInstance(profile._profilers.profiler, profile.Profiler)
     self.assertEqual(
         set(profile._profilers.actions), set(('callgrind', 'show')))
コード例 #28
0
 def endRequest(self, path='/', exception=None, pageid=None, work=None):
     start_event = self._get_start_event(path)
     da.set_request_started()
     profile.start_request(start_event)
     request = start_event.request
     if pageid is not None:
         request.setInWSGIEnvironment('launchpad.pageid', pageid)
     if work is not None:
         work()
     request.response.setResult(EXAMPLE_HTML)
     context = object()
     event = EndRequestEvent(context, request)
     if exception is not None:
         self.eru.raising((type(exception), exception, None), event.request)
     profile.end_request(event)
     da.clear_request_started()
     return event.request
コード例 #29
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def endRequest(self, path='/', exception=None, pageid=None, work=None):
     start_event = self._get_start_event(path)
     da.set_request_started()
     profile.start_request(start_event)
     request = start_event.request
     if pageid is not None:
         request.setInWSGIEnvironment('launchpad.pageid', pageid)
     if work is not None:
         work()
     request.response.setResult(EXAMPLE_HTML)
     context = object()
     event = EndRequestEvent(context, request)
     if exception is not None:
         self.eru.raising(
             (type(exception), exception, None), event.request)
     profile.end_request(event)
     da.clear_request_started()
     return event.request
コード例 #30
0
ファイル: tests.py プロジェクト: pombreda/UnnaturalCodeFork
 def test_sql_start(self):
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/++profile++sql/'))
     self.assertIs(getattr(profile._profilers, 'profiler', None), None)
     self.assertEquals(profile._profilers.actions, dict(sql=False))
     self.assertEqual([], da.stop_sql_logging())
コード例 #31
0
ファイル: tests.py プロジェクト: pombredanne/launchpad-3
 def test_sql_start(self):
     self.pushProfilingConfig(profiling_allowed='True')
     profile.start_request(self._get_start_event('/++profile++sql/'))
     self.assertIs(getattr(profile._profilers, 'profiler', None), None)
     self.assertEqual(profile._profilers.actions, dict(sql=False))
     self.assertEqual([], da.stop_sql_logging())