{"action":"created","issue":{"url":"https://api.github.com/repos/sunpy/sunpy/issues/1277","labels_url":"https://api.github.com/repos/sunpy/sunpy/issues/1277/labels{/name}","comments_url":"https://api.github.com/repos/sunpy/sunpy/issues/1277/comments","events_url":"https://api.github.com/repos/sunpy/sunpy/issues/1277/events","html_url":"https://github.com/sunpy/sunpy/pull/1277","id":55838893,"number":1277,"title":"Hash-based figure verification for tests","user":{"login":"ayshih","id":991759,"avatar_url":"https://avatars.githubusercontent.com/u/991759?v=3","gravatar_id":"","url":"https://api.github.com/users/ayshih","html_url":"https://github.com/ayshih","followers_url":"https://api.github.com/users/ayshih/followers","following_url":"https://api.github.com/users/ayshih/following{/other_user}","gists_url":"https://api.github.com/users/ayshih/gists{/gist_id}","starred_url":"https://api.github.com/users/ayshih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayshih/subscriptions","organizations_url":"https://api.github.com/users/ayshih/orgs","repos_url":"https://api.github.com/users/ayshih/repos","events_url":"https://api.github.com/users/ayshih/events{/privacy}","received_events_url":"https://api.github.com/users/ayshih/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sunpy/sunpy/labels/Tests","name":"Tests","color":"0052cc"},{"url":"https://api.github.com/repos/sunpy/sunpy/labels/[WIP]","name":"[WIP]","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-01-29T00:39:08Z","updated_at":"2015-01-29T20:48:23Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sunpy/sunpy/pulls/1277","html_url":"https://github.com/sunpy/sunpy/pull/1277","diff_url":"https://github.com/sunpy/sunpy/pull/1277.diff","patch_url":"https://github.com/sunpy/sunpy/pull/1277.patch"},"body":"Here is a proof of concept, and hopefully an acceptable implementation, of hash-based figure verification for tests (see also #410 and #1175).\r\n\r\n## How to use the test decorator\r\n```python\r\nfrom sunpy.tests.helpers import figure_test\r\n\r\n@figure_test\r\ndef test_rotate_by_20():\r\n    aia_map = sunpy.map.Map(sunpy.AIA_171_IMAGE)\r\n    aia_map.rotate(20).plot()\r\n```\r\nBy default, the current figure (via `plt.gcf()`) is hashed, but you can explicitly return a figure from the test function if you wish.  The hashes are identified by test-function name in the hash library.  All such decorated tests are marked with `pytest.mark.figure` so that you can use a call like `py.test -m figure` to run only the figure tests.\r\n\r\n## Updating the hash library\r\nThe hashes are stored in a JSON file `sunpy/tests/figure_hashes.json`, which is tracked by Git.  If you add a new decorated test function, the specific test will fail to let you know that the hash library needs to be expanded.  When the pytest run completes, the addition of any new hashes will trigger the creation of a new JSON file in a temporary directory (the path is printed in the test output).  You will then need to manually replace the tracked JSON file with the new JSON file so that the tests will pass.\r\n\r\n## Missing in this PR\r\n* Documentation\r\n* Any capability for a visual dictionary to match images and hashes\r\n* Changelog, of course!"},"comment":{"url":"https://api.github.com/repos/sunpy/sunpy/issues/comments/72101121","html_url":"https://github.com/sunpy/sunpy/pull/1277#issuecomment-72101121","issue_url":"https://api.github.com/repos/sunpy/sunpy/issues/1277","id":72101121,"user":{"login":"Cadair","id":1391051,"avatar_url":"https://avatars.githubusercontent.com/u/1391051?v=3","gravatar_id":"","url":"https://api.github.com/users/Cadair","html_url":"https://github.com/Cadair","followers_url":"https://api.github.com/users/Cadair/followers","following_url":"https://api.github.com/users/Cadair/following{/other_user}","gists_url":"https://api.github.com/users/Cadair/gists{/gist_id}","starred_url":"https://api.github.com/users/Cadair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cadair/subscriptions","organizations_url":"https://api.github.com/users/Cadair/orgs","repos_url":"https://api.github.com/users/Cadair/repos","events_url":"https://api.github.com/users/Cadair/events{/privacy}","received_events_url":"https://api.github.com/users/Cadair/received_events","type":"User","site_admin":false},"created_at":"2015-01-29T20:48:23Z","updated_at":"2015-01-29T20:48:23Z","body":"I think this implementation is good.\r\n\r\nWhat do you think about a reference lib?"}}