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

Skip to content

Commit a89d7d2

Browse files
committed
Don't start a browser for visual tests on CI.
Travis may or may not have a browser installed, but AppVeyor definitely does, so this saves a tiny bit of processing power per run.
1 parent ccca1f3 commit a89d7d2

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ test_script:
139139
- if x%USE_PYTEST% == xyes py.test %PYTEST_ARGS%
140140
- if x%USE_PYTEST% == xno python tests.py %PYTEST_ARGS%
141141
# Generate a html for visual tests
142-
- python visual_tests.py
142+
- python visual_tests.py --no-browser
143143
- pip install codecov
144144
- codecov -e PYTHON_VERSION PLATFORM
145145

@@ -180,7 +180,7 @@ artifacts:
180180
on_finish:
181181

182182
on_failure:
183-
- python visual_tests.py
183+
- python visual_tests.py --no-browser
184184
- echo zipping images after a failure...
185185
- 7z a result_images.zip result_images\ |grep -v "Compressing"
186186
- appveyor PushArtifact result_images.zip

visual_tests.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# $ python visual_tests.py
77
#
88

9+
import argparse
910
import os
1011
from collections import defaultdict
1112

@@ -44,7 +45,7 @@
4445
linked_image_template = '<a href="{0}"><img src="{0}"></a>'
4546

4647

47-
def run():
48+
def run(show_browser=True):
4849
"""
4950
Build a website for visual comparison
5051
"""
@@ -116,12 +117,21 @@ def run():
116117
with open(index, "w") as f:
117118
f.write(html)
118119

119-
try:
120-
import webbrowser
121-
webbrowser.open(index)
122-
except:
120+
show_message = not show_browser
121+
if show_browser:
122+
try:
123+
import webbrowser
124+
webbrowser.open(index)
125+
except:
126+
show_message = True
127+
128+
if show_message:
123129
print("Open {} in a browser for a visual comparison.".format(index))
124130

125131

126132
if __name__ == '__main__':
127-
run()
133+
parser = argparse.ArgumentParser()
134+
parser.add_argument('--no-browser', action='store_true',
135+
help="Don't show browser after creating index page.")
136+
args = parser.parse_args()
137+
run(show_browser=not args.no_browser)

0 commit comments

Comments
 (0)