Skip to content

Commit 053cdd6

Browse files
committed
Quick fix for intermittent image server tests.
Just wrapping them in a loop so that we can retry as needed for now.
1 parent 8850feb commit 053cdd6

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

plotly/tests/test_core/test_image/test_image.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
import tempfile
66
import os
77
import itertools
8+
import warnings
89

910
from nose.plugins.attrib import attr
1011

12+
from plotly import exceptions
1113
from plotly.plotly import plotly as py
1214

1315

@@ -24,9 +26,20 @@ def setUp(self):
2426
def _generate_image_get_returns_valid_image_test(image_format,
2527
width, height, scale):
2628
def test(self):
27-
image = py.image.get(self.data, image_format, width, height, scale)
28-
if image_format in ['png', 'jpeg']:
29-
assert imghdr.what('', image) == image_format
29+
# TODO: better understand why this intermittently fails. See #649
30+
num_attempts = 5
31+
for i in range(num_attempts):
32+
if i > 0:
33+
warnings.warn('image test intermittently failed, retrying...')
34+
try:
35+
image = py.image.get(self.data, image_format, width, height,
36+
scale)
37+
if image_format in ['png', 'jpeg']:
38+
assert imghdr.what('', image) == image_format
39+
return
40+
except (KeyError, exceptions.PlotlyError):
41+
if i == num_attempts - 1:
42+
raise
3043

3144
return test
3245

0 commit comments

Comments
 (0)