def test_allow_unknown_if_matching(self): merger = merge_results.JSONTestResultsMerger(allow_unknown_if_matching=False) self.assertEqual( {'version': 3.0}, merger.merge([{'version': 3.0}, {'version': 3.0}])) with self.assertRaises(merge_results.MergeFailure): merger.merge([{'random': 'hello'}, {'random': 'hello'}]) merger = merge_results.JSONTestResultsMerger(allow_unknown_if_matching=True) self.assertEqual( {'random': 'hello'}, merger.merge([{'random': 'hello'}, {'random': 'hello'}]))
def test_summable(self): merger = merge_results.JSONTestResultsMerger() self.assertEqual({'fixable': 5}, merger.merge([{ 'fixable': 2 }, { 'fixable': 3 }])) self.assertEqual({'num_failures_by_type': { 'A': 4, 'B': 3, 'C': 2 }}, merger.merge([ { 'num_failures_by_type': { 'A': 3, 'B': 1 } }, { 'num_failures_by_type': { 'A': 1, 'B': 2, 'C': 2 } }, ]))
def test_seconds_since_epoch(self): merger = merge_results.JSONTestResultsMerger() self.assertEqual({'seconds_since_epoch': 2}, merger.merge({'seconds_since_epoch': 3}, {'seconds_since_epoch': 2})) self.assertEqual({'seconds_since_epoch': 2}, merger.merge({'seconds_since_epoch': 2}, {'seconds_since_epoch': 3})) self.assertEqual({'seconds_since_epoch': 12}, merger.merge({'seconds_since_epoch': 12}, {}))
def test_interrupted(self): merger = merge_results.JSONTestResultsMerger() self.assertEqual( {'interrupted': False}, merger.merge([{'interrupted': False}, {'interrupted': False}])) self.assertEqual( {'interrupted': True}, merger.merge([{'interrupted': True}, {'interrupted': False}])) self.assertEqual( {'interrupted': True}, merger.merge([{'interrupted': False}, {'interrupted': True}]))