tesseract v5.3.3.20231005
gtest_json_test_utils Namespace Reference

Functions

def normalize (obj)
 

Function Documentation

◆ normalize()

def gtest_json_test_utils.normalize (   obj)
Normalize output object.

Args:
   obj: Google Test's JSON output object to normalize.

Returns:
   Normalized output without any references to transient information that may
   change from run to run.

Definition at line 35 of file gtest_json_test_utils.py.

35def normalize(obj):
36 """Normalize output object.
37
38 Args:
39 obj: Google Test's JSON output object to normalize.
40
41 Returns:
42 Normalized output without any references to transient information that may
43 change from run to run.
44 """
45 def _normalize(key, value):
46 if key == 'time':
47 return re.sub(r'^\d+(\.\d+)?s$', '*', value)
48 elif key == 'timestamp':
49 return re.sub(r'^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ$', '*', value)
50 elif key == 'failure':
51 value = re.sub(r'^.*[/\\](.*:)\d+\n', '\\1*\n', value)
52 return re.sub(r'Stack trace:\n(.|\n)*', 'Stack trace:\n*', value)
53 else:
54 return normalize(value)
55 if isinstance(obj, dict):
56 return {k: _normalize(k, v) for k, v in obj.items()}
57 if isinstance(obj, list):
58 return [normalize(x) for x in obj]
59 else:
60 return obj