30
30
("my_regressions" , MY_REGRESSION_TESTS_DIR ),
31
31
)
32
32
33
+ DEFAULT_FORMAT = "png"
34
+
33
35
34
36
def list_dots (path ):
35
37
searchpath = os .path .join (path , "*.dot" )
@@ -57,7 +59,7 @@ def pytest_generate_tests(metafunc):
57
59
58
60
def _render_with_graphviz (filename ):
59
61
p = subprocess .Popen (
60
- (DOT_BINARY_PATH , "-Tjpe" ),
62
+ (DOT_BINARY_PATH , "-T{}" . format ( DEFAULT_FORMAT ) ),
61
63
cwd = os .path .dirname (filename ),
62
64
stdin = open (filename , "rt" ),
63
65
stderr = subprocess .PIPE ,
@@ -77,8 +79,8 @@ def _render_with_graphviz(filename):
77
79
if stdout_output :
78
80
stdout_output = NULL_SEP .join (stdout_output )
79
81
80
- # this returns a status code we should check
81
- p . wait ()
82
+ ret = p . wait ()
83
+ assert ret == 0 , "graphviz quit with error"
82
84
83
85
return sha256 (stdout_output ).hexdigest ()
84
86
@@ -87,8 +89,8 @@ def _render_with_pydot(filename):
87
89
g = pydot .graph_from_dot_file (filename )
88
90
if not isinstance (g , list ):
89
91
g = [g ]
90
- jpe_data = NULL_SEP .join ([_g .create (format = "jpe" ) for _g in g ])
91
- return sha256 (jpe_data ).hexdigest ()
92
+ image_data = NULL_SEP .join ([_g .create (format = DEFAULT_FORMAT ) for _g in g ])
93
+ return sha256 (image_data ).hexdigest ()
92
94
93
95
94
96
def test_render_and_compare_dot_files (filepath ):
@@ -113,8 +115,8 @@ def test_graph_with_shapefiles():
113
115
#
114
116
g = pydot .graph_from_dot_data (graph_data )
115
117
g .set_shape_files (pngs )
116
- jpe_data = g .create (format = "jpe" )
117
- hexdigest = sha256 (jpe_data ).hexdigest ()
118
+ image_data = g .create (format = DEFAULT_FORMAT )
119
+ hexdigest = sha256 (image_data ).hexdigest ()
118
120
hexdigest_original = _render_with_graphviz (dot_file )
119
121
120
122
assert hexdigest == hexdigest_original
0 commit comments