Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Unified Diff: tools/telemetry/telemetry/page/page_run_end_to_end_unittest.py

Issue 1047613002: Revert of [Telemetry] Do not close tab connections if the tab is already gone. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/telemetry/telemetry/page/shared_page_state.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/page/page_run_end_to_end_unittest.py
diff --git a/tools/telemetry/telemetry/page/page_run_end_to_end_unittest.py b/tools/telemetry/telemetry/page/page_run_end_to_end_unittest.py
index 88b770d7a31a239050af3ddbe731dc9adf01501b..6d4d8e58af1865834ab8de7c34347c09e1002888 100644
--- a/tools/telemetry/telemetry/page/page_run_end_to_end_unittest.py
+++ b/tools/telemetry/telemetry/page/page_run_end_to_end_unittest.py
@@ -5,8 +5,6 @@
import os
import unittest
import shutil
-import sys
-import StringIO
import tempfile
from telemetry import benchmark
@@ -24,7 +22,7 @@
from telemetry.unittest_util import options_for_unittests
from telemetry.unittest_util import system_stub
from telemetry.user_story import user_story_runner
-from telemetry.util import exception_formatter
+from telemetry.util import exception_formatter as exception_formatter_module
from unittest_data.page_sets import example_domain
@@ -75,14 +73,11 @@
return [run for run in results.all_page_runs if run.ok or run.skipped]
-def CaptureStderr(func, output_buffer):
- def wrapper(*args, **kwargs):
- original_stderr, sys.stderr = sys.stderr, output_buffer
- try:
- return func(*args, **kwargs)
- finally:
- sys.stderr = original_stderr
- return wrapper
+class FakeExceptionFormatterModule(object):
+ @staticmethod
+ def PrintFormattedException(
+ exception_class=None, exception=None, tb=None, msg=None):
+ pass
# TODO: remove test cases that use real browsers and replace with a
@@ -93,22 +88,14 @@
def setUp(self):
self._user_story_runner_logging_stub = None
- self._formatted_exception_buffer = StringIO.StringIO()
- self._original_formatter = exception_formatter.PrintFormattedException
-
- def CaptureFormattedException(self):
- exception_formatter.PrintFormattedException = CaptureStderr(
- exception_formatter.PrintFormattedException,
- self._formatted_exception_buffer)
+
+ def SuppressExceptionFormatting(self):
+ user_story_runner.exception_formatter = FakeExceptionFormatterModule
self._user_story_runner_logging_stub = system_stub.Override(
- user_story_runner, ['logging'])
-
- @property
- def formatted_exception(self):
- return self._formatted_exception_buffer.getvalue()
+ user_story_runner, ['logging'])
def RestoreExceptionFormatter(self):
- exception_formatter.PrintFormattedException = self._original_formatter
+ user_story_runner.exception_formatter = exception_formatter_module
if self._user_story_runner_logging_stub:
self._user_story_runner_logging_stub.Restore()
self._user_story_runner_logging_stub = None
@@ -117,7 +104,7 @@
self.RestoreExceptionFormatter()
def testRaiseBrowserGoneExceptionFromRestartBrowserBeforeEachPage(self):
- self.CaptureFormattedException()
+ self.SuppressExceptionFormatting()
ps = page_set.PageSet()
expectations = test_expectations.TestExpectations()
ps.pages.append(page_module.Page(
@@ -151,10 +138,9 @@
self.assertEquals(2, test.run_count)
self.assertEquals(1, len(GetSuccessfulPageRuns(results)))
self.assertEquals(1, len(results.failures))
- self.assertEquals('', self.formatted_exception)
def testNeedsBrowserRestartAfterEachPage(self):
- self.CaptureFormattedException()
+ self.SuppressExceptionFormatting()
ps = page_set.PageSet()
expectations = test_expectations.TestExpectations()
ps.pages.append(page_module.Page(
@@ -183,10 +169,9 @@
user_story_runner.Run(test, ps, expectations, options, results)
self.assertEquals(2, len(GetSuccessfulPageRuns(results)))
self.assertEquals(2, test.browser_starts)
- self.assertEquals('', self.formatted_exception)
def testHandlingOfCrashedTabWithExpectedFailure(self):
- self.CaptureFormattedException()
+ self.SuppressExceptionFormatting()
ps = page_set.PageSet()
expectations = test_expectations.TestExpectations()
expectations.Fail('chrome://crash')
@@ -201,18 +186,14 @@
user_story_runner.Run(DummyTest(), ps, expectations, options, results)
self.assertEquals(1, len(GetSuccessfulPageRuns(results)))
self.assertEquals(0, len(results.failures))
- self.assertIn('DevtoolsTargetCrashException', self.formatted_exception)
- # Check that only one exception is raised.
- self.assertEquals(1, self.formatted_exception.count('Traceback'))
def testCredentialsWhenLoginFails(self):
- self.CaptureFormattedException()
+ self.SuppressExceptionFormatting()
credentials_backend = StubCredentialsBackend(login_return_value=False)
did_run = self.runCredentialsTest(credentials_backend)
assert credentials_backend.did_get_login == True
assert credentials_backend.did_get_login_no_longer_needed == False
assert did_run == False
- self.assertEquals('', self.formatted_exception)
def testCredentialsWhenLoginSucceeds(self):
credentials_backend = StubCredentialsBackend(login_return_value=True)
@@ -503,6 +484,7 @@
shutil.rmtree(options.output_dir)
def _RunPageTestThatRaisesAppCrashException(self, test, max_failures):
+ self.SuppressExceptionFormatting()
class TestPage(page_module.Page):
def RunNavigateSteps(self, _):
raise exceptions.AppCrashException
@@ -522,7 +504,6 @@
return results
def testSingleTabMeansCrashWillCauseFailureValue(self):
- self.CaptureFormattedException()
class SingleTabTest(page_test.PageTest):
# Test is not multi-tab because it does not override TabForPage.
def ValidateAndMeasurePage(self, *_):
@@ -532,11 +513,9 @@
results = self._RunPageTestThatRaisesAppCrashException(test, max_failures=1)
self.assertEquals([], GetSuccessfulPageRuns(results))
self.assertEquals(2, len(results.failures)) # max_failures + 1
- self.assertEquals('', self.formatted_exception)
@decorators.Enabled('has tabs')
def testMultipleTabsMeansCrashRaises(self):
- self.CaptureFormattedException()
class MultipleTabsTest(page_test.PageTest):
# Test *is* multi-tab because it overrides TabForPage.
def TabForPage(self, page, browser):
@@ -547,9 +526,6 @@
test = MultipleTabsTest()
with self.assertRaises(page_test.MultiTabTestAppCrashError):
self._RunPageTestThatRaisesAppCrashException(test, max_failures=1)
- self.assertIn('AppCrashException', self.formatted_exception)
- # Check that only one exception is raised.
- self.assertEquals(1, self.formatted_exception.count('Traceback'))
def testWebPageReplay(self):
ps = example_domain.ExampleDomainPageSet()
« no previous file with comments | « no previous file | tools/telemetry/telemetry/page/shared_page_state.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698