percy / python-percy-client

[Deprecated] Python client library for visual regression testing with Percy.
https://percy.io/docs/clients/python/selenium
MIT License
21 stars 24 forks source link

Raise an exception for 4xx and 5xx status codes and print the content #29

Closed chriddyp closed 7 years ago

chriddyp commented 7 years ago

This is to help out debugging. Before this, my error messages on CircleCI were like:

----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_integration.py", line 126, in test_integration
    name='dash_core_components - {}'.format(python_version)
  File "/home/ubuntu/dash-core-components/.tox/py27/lib/python2.7/site-packages/percy/runner.py", line 84, in snapshot
    missing_resources = snapshot_data['data']['relationships']['missing-resources']
KeyError: 'data'

After this, my error messages are a little more informative:

{"errors":[{"status":"bad_request","detail":"Invalid URL or path: ,"}]}
E
======================================================================
ERROR: test_integration (test.test_integration.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_integration.py", line 126, in test_integration
    name='dash_core_components - {}'.format(python_version)
  File "/home/ubuntu/dash-core-components/.tox/py27/lib/python2.7/site-packages/percy/runner.py", line 82, in snapshot
    snapshot_data = self.client.create_snapshot(build_id, [root_resource], **kwargs)
  File "/home/ubuntu/dash-core-components/.tox/py27/lib/python2.7/site-packages/percy/client.py", line 104, in create_snapshot
    return self._connection.post(path=path, data=data)
  File "/home/ubuntu/dash-core-components/.tox/py27/lib/python2.7/site-packages/percy/connection.py", line 36, in post
    raise e
HTTPError: 400 Client Error: Bad Request for url: https://percy.io/api/v1/builds/319715/snapshots/
chriddyp commented 7 years ago

Related to https://github.com/percy/python-percy-client/issues/24 and https://github.com/percy/python-percy-client/issues/12.

If anyone was seeing these issues and wants to try this fork in their tests, you can install with:

pip install git+git://github.com/chriddyp/python-percy-client.git

or in your requirements.txt like:

git+git://github.com/chriddyp/python-percy-client.git
teeberg commented 7 years ago

I've also done some work around this in https://github.com/percy/python-percy-client/pull/13, which unfortunately hasn't gotten any attention so far

timhaines commented 7 years ago

@teeberg a PR from 2016?! Sorry about that! We'll take a look at that this week!

timhaines commented 7 years ago

Thanks for this PR @chriddyp! I cherry-picked your first commit here, and added a bit more to it in https://github.com/percy/python-percy-client/pull/30. Will be merging and publishing this soon.

chriddyp commented 7 years ago

Thanks @timhaines !!

timhaines commented 7 years ago

@chriddyp Published as v1.0.5 :)