Title: check_figures_equal decorator reuses figures if called multiple times inside a single test. · Issue #15079 · matplotlib/matplotlib · GitHub
Open Graph Title: check_figures_equal decorator reuses figures if called multiple times inside a single test. · Issue #15079 · matplotlib/matplotlib
X Title: check_figures_equal decorator reuses figures if called multiple times inside a single test. · Issue #15079 · matplotlib/matplotlib
Description: Bug report Bug summary When running a test suite with multiple tests using check_figures_equal, figures are re-used, causing plot elements to become "stacked", causing tests to unexpectedly fail. Code for reproduction from matplotlib.tes...
Open Graph Description: Bug report Bug summary When running a test suite with multiple tests using check_figures_equal, figures are re-used, causing plot elements to become "stacked", causing tests to unexpectedly fail. C...
X Description: Bug report Bug summary When running a test suite with multiple tests using check_figures_equal, figures are re-used, causing plot elements to become "stacked", causing tests to unexpected...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/15079
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"check_figures_equal decorator reuses figures if called multiple times inside a single test.","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nWhen running a test suite with multiple tests using check_figures_equal, figures are re-used, causing plot elements to become \"stacked\", causing tests to unexpectedly fail.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nfrom matplotlib.testing.decorators import check_figures_equal\r\nfrom matplotlib import pyplot as plt\r\n\r\n@check_figures_equal(extensions=[\"png\"])\r\ndef test_red_line_first(test_figure, reference_figure):\r\n red_circle = plt.Circle((0, 0), 0.2, color='r', clip_on=False)\r\n reference_figure.add_artist(red_circle)\r\n reference_figure.subplots().plot([0,1,2], [3,4,5], color='red') \r\n\r\n\r\n@check_figures_equal(extensions=[\"png\"])\r\ndef test_blue_line_second(test_figure, reference_figure):\r\n blue_circle = plt.Circle((1, 1), 0.2, color='b', clip_on=False)\r\n reference_figure.add_artist(blue_circle)\r\n reference_figure.subplots().plot([0,1,2], [4,4,4], color='blue')\r\n\r\n\r\n@check_figures_equal(extensions=[\"png\"])\r\ndef test_green_line_third(test_figure, reference_figure):\r\n green_circle = plt.Circle((1, 0), 0.2, color='g', clip_on=False)\r\n reference_figure.add_artist(green_circle)\r\n reference_figure.subplots().plot([0,1,2], [5,4,3], color='green')\r\n```\r\n\r\nrunning as:\r\n`pytest .\\mpl_figure_equal_test.py`\r\n\r\n**Actual outcome**\r\nReference Screenshots:\r\n\r\n\r\n\r\n\r\n\r\n**Expected outcome**\r\nReference Screenshots:\r\n\r\n\r\n\r\n\r\n\u003c!--A description of the expected outcome from the code snippet--\u003e\r\n\u003c!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on--\u003e\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: `Windows 10`\r\n * Matplotlib version: `matplotlib 3.1.0`\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): `TkAgg`\r\n * Python version: `3.7.3`\r\n * Jupyter version (if applicable):\r\n * Other libraries: `pytest 4.5.0`\r\n\r\neverything installed via pip\r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\nhttps://github.com/matplotlib/matplotlib/blob/e86c9cd7105e107589220286d55cd9ffc3bfeb64/lib/matplotlib/testing/decorators.py#L394-L395\r\n\r\nI'm guessing these lines are at fault, and might need some kind of other information to distinguish them?\r\n","author":{"url":"https://github.com/andrewzwicky","@type":"Person","name":"andrewzwicky"},"datePublished":"2019-08-18T18:14:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/15079/matplotlib/issues/15079"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c1ac430c-1bf1-9615-3a05-ac01bf692a92 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBB4:12E3C6:EEE038:13CEE72:6A51B9AC |
| html-safe-nonce | 9e3c3af11d7cd7b077fe3a48728de7479a1baccbd7579dd5c4d8cc159e6427df |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkI0OjEyRTNDNjpFRUUwMzg6MTNDRUU3Mjo2QTUxQjlBQyIsInZpc2l0b3JfaWQiOiIyODIwMjc4MzQ1MjgyOTkyNTU2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9f5db0c6ce7d5deca21b7548d76d6c36b407c02cfe6f1b8b01eab84f0ff88975 |
| hovercard-subject-tag | issue:482021802 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/15079/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7e9c3069a486cbe674a400caf323ce5a204985b99f657def72c21da710efe240/matplotlib/matplotlib/issues/15079 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7e9c3069a486cbe674a400caf323ce5a204985b99f657def72c21da710efe240/matplotlib/matplotlib/issues/15079 |
| og:image:alt | Bug report Bug summary When running a test suite with multiple tests using check_figures_equal, figures are re-used, causing plot elements to become "stacked", causing tests to unexpectedly fail. C... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andrewzwicky |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width