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
--- 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]: