Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7cd4cc9

Browse files
committed
PEP8 visual_tests.py.
1 parent 3891566 commit 7cd4cc9

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pep8ignore =
1515
setupext.py E301 E302 E501
1616
setup_external_compile.py E302 E501 E711
1717
versioneer.py ALL # External file.
18-
visual_tests.py E302 E501
1918

2019
matplotlib/backends/qt_editor/formlayout.py E301 E402 E501
2120
matplotlib/backends/backend_agg.py E225 E228 E231 E261 E301 E302 E303 E501 E701

visual_tests.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#
88

99
import os
10-
import time
1110
import six
1211

1312
from collections import defaultdict
@@ -48,18 +47,21 @@
4847

4948

5049
def run():
51-
# Build a website for visual comparison
50+
"""
51+
Build a website for visual comparison
52+
"""
5253
image_dir = "result_images"
53-
# build the website
54-
_subdirs = [name for name in os.listdir(image_dir) if os.path.isdir(os.path.join(image_dir, name))]
55-
# loop over all pictures
56-
_has_failure = False
54+
_subdirs = (name
55+
for name in os.listdir(image_dir)
56+
if os.path.isdir(os.path.join(image_dir, name)))
57+
5758
failed_rows = []
5859
body_sections = []
5960
for subdir in _subdirs:
6061
if subdir == "test_compare_images":
61-
# these are the image which test the image comparison functions...
62+
# These are the images which test the image comparison functions.
6263
continue
64+
6365
pictures = defaultdict(dict)
6466
for file in os.listdir(os.path.join(image_dir, subdir)):
6567
if os.path.isdir(os.path.join(image_dir, subdir, file)):
@@ -81,16 +83,15 @@ def run():
8183
actual_image = test.get('c', '')
8284

8385
if 'f' in test:
84-
# a real failure in the image generation, resulting in different images
85-
_has_failure = True
86+
# A real failure in the image generation, resulting in
87+
# different images.
8688
status = " (failed)"
8789
failed = '<a href="{0}">diff</a>'.format(test['f'])
8890
current = linked_image_template.format(actual_image)
8991
failed_rows.append(row_template.format(name, "", current,
9092
expected_image, failed))
9193
elif 'c' not in test:
9294
# A failure in the test, resulting in no current image
93-
_has_failure = True
9495
status = " (failed)"
9596
failed = '--'
9697
current = '(Failure in test, no image produced)'
@@ -100,13 +101,14 @@ def run():
100101
status = " (passed)"
101102
failed = '--'
102103
current = linked_image_template.format(actual_image)
104+
103105
subdir_rows.append(row_template.format(name, status, current,
104106
expected_image, failed))
105107

106108
body_sections.append(
107109
subdir_template.format(subdir=subdir, rows='\n'.join(subdir_rows)))
108110

109-
if _has_failure:
111+
if failed_rows:
110112
failed = failed_template.format(rows='\n'.join(failed_rows))
111113
else:
112114
failed = ''
@@ -122,5 +124,6 @@ def run():
122124
except:
123125
print("Open {} in a browser for a visual comparison.".format(index))
124126

127+
125128
if __name__ == '__main__':
126129
run()

0 commit comments

Comments
 (0)