Bug 1411045 - Display error when response is unsuccessful. r?maja_zf draft
authorAndreas Tolfsen <ato@sny.no>
Mon, 23 Oct 2017 22:15:53 +0100
changeset 685980 6444720f07af39e3fa4bdab35135d7358d526d65
parent 685979 699e988013340943fd4526860ad77369c206a7aa
child 737260 04fdc82300c2d6a2f487ad43ac1d83d78dade6b9
push id86054
push userbmo:ato@sny.no
push dateWed, 25 Oct 2017 07:41:54 +0000
reviewersmaja_zf
bugs1411045
milestone58.0a1
Bug 1411045 - Display error when response is unsuccessful. r?maja_zf Instead of the default pytest error message when the assertion fails, which is rather pointless because we know we did not match the 200 HTTP status code, display the string representation of wdclient.error.WebDriverException. This string representation includes the remote end's stacktrace, which is infinitely more useful in this context. MozReview-Commit-ID: 6XUgEEc9Qoj
testing/web-platform/tests/webdriver/tests/support/asserts.py
--- a/testing/web-platform/tests/webdriver/tests/support/asserts.py
+++ b/testing/web-platform/tests/webdriver/tests/support/asserts.py
@@ -63,45 +63,49 @@ def assert_error(response, error_code):
     :param error_code: string value of the expected "error code"
     """
     assert response.status == errors[error_code]
     assert "value" in response.body
     assert response.body["value"]["error"] == error_code
     assert isinstance(response.body["value"]["message"], basestring)
     assert isinstance(response.body["value"]["stacktrace"], basestring)
 
+
 def assert_success(response, value=None):
     """Verify that the provided wdclient.Response instance described a valid
     error response as defined by `dfn-send-an-error` and the provided error
     code.
 
     :param response: wdclient.Response instance.
     :param value: Expected value of the response body, if any.
 
     """
-    assert response.status == 200
+    assert response.status == 200, str(response.error)
+
     if value is not None:
         assert response.body["value"] == value
     return response.body.get("value")
 
+
 def assert_dialog_handled(session, expected_text):
     result = session.transport.send("GET",
                                     "session/%s/alert/text" % session.session_id)
 
     # If there were any existing dialogs prior to the creation of this
     # fixture's dialog, then the "Get Alert Text" command will return
     # successfully. In that case, the text must be different than that
     # of this fixture's dialog.
     try:
         assert_error(result, "no such alert")
     except:
         assert (result.status == 200 and
                 result.body["value"] != expected_text), (
                "Dialog with text '%s' was not handled." % expected_text)
 
+
 def assert_same_element(session, a, b):
     """Verify that two element references describe the same element."""
     assert isinstance(a, dict), "Actual value is not a dictionary"
     assert isinstance(b, dict), "Expected value is not a dictionary"
     assert element_key in a, "Actual value does not describe an element"
     assert element_key in b, "Expected value does not describe an element"
 
     if a[element_key] == b[element_key]: