@@ -136,17 +136,56 @@ def combine(*results):
136
136
for result in results :
137
137
for dataset in result [1 :]:
138
138
for test , result in dataset .items ():
139
+ if "::" not in test :
140
+ # Convert nosetests results in to pytest format
141
+ path , test = test .split (':' )
142
+ test = '/' .join (path .split ('.' )) + '.py::' \
143
+ + '::' .join (test .split ('.' ))
139
144
if test not in ans :
140
145
ans [test ] = {}
141
146
testdata = ans [test ]
142
147
for metric , value in result .items ():
143
148
if type (value ) is dict :
144
149
continue
145
150
testdata .setdefault (metric , []).append (value )
151
+ # Nosetests and pytest would give different test names (based on
152
+ # where they started including path elements). We will assume that
153
+ # tests should be uniquely declared by the test file, class, and
154
+ # test name. So, any two tests where one name ends with the
155
+ # complete name of the other will be assumed to be the same test and
156
+ # combined.
157
+ for base in list (ans ):
158
+ for test in ans :
159
+ if test == base :
160
+ break
161
+ if test .endswith (base ):
162
+ testdata = ans [test ]
163
+ otherdata = ans .pop (base )
164
+ for metric , value in otherdata .items ():
165
+ testdata .setdefault (metric , []).append (value )
166
+ break
146
167
return ans
147
168
148
169
def compare (base_data , test_data ):
149
170
"""Compare two data sets (generated by compare())"""
171
+ # Nosetests and pytest would give different test names (based on
172
+ # where they started including path elements). We will assume that
173
+ # tests should be uniquely declared by the test file, class, and
174
+ # test name. So, any two tests where one name ends with the
175
+ # complete name of the other will be assumed to be the same test.
176
+ # We will make both to the "more specific" (longer) name before
177
+ # comparing.
178
+ for base in list (base_data ):
179
+ for test in test_data :
180
+ if base == test :
181
+ break
182
+ if test .endswith (base ):
183
+ base_data [test ] = base_data .pop (base )
184
+ break
185
+ if base .endswith (test ):
186
+ test_data [base ] = test_data .pop (test )
187
+ break
188
+
150
189
fields = set ()
151
190
for testname , base in base_data .items ():
152
191
if testname not in test_data :
0 commit comments