@@ -56,6 +56,7 @@ def _test():
5656 'ELLIPSIS' ,
5757 'SKIP' ,
5858 'IGNORE_EXCEPTION_DETAIL' ,
59+ 'IGNORE_EXCEPTION_TIMESTAMPS' ,
5960 'COMPARISON_FLAGS' ,
6061 'REPORT_UDIFF' ,
6162 'REPORT_CDIFF' ,
@@ -157,13 +158,15 @@ def register_optionflag(name):
157158ELLIPSIS = register_optionflag ('ELLIPSIS' )
158159SKIP = register_optionflag ('SKIP' )
159160IGNORE_EXCEPTION_DETAIL = register_optionflag ('IGNORE_EXCEPTION_DETAIL' )
161+ IGNORE_EXCEPTION_TIMESTAMPS = register_optionflag ('IGNORE_EXCEPTION_TIMESTAMPS' )
160162
161163COMPARISON_FLAGS = (DONT_ACCEPT_TRUE_FOR_1 |
162164 DONT_ACCEPT_BLANKLINE |
163165 NORMALIZE_WHITESPACE |
164166 ELLIPSIS |
165167 SKIP |
166- IGNORE_EXCEPTION_DETAIL )
168+ IGNORE_EXCEPTION_DETAIL |
169+ IGNORE_EXCEPTION_TIMESTAMPS )
167170
168171REPORT_UDIFF = register_optionflag ('REPORT_UDIFF' )
169172REPORT_CDIFF = register_optionflag ('REPORT_CDIFF' )
@@ -273,7 +276,7 @@ def _exception_traceback(exc_info):
273276 # Get a traceback message.
274277 excout = StringIO ()
275278 exc_type , exc_val , exc_tb = exc_info
276- traceback .print_exception (exc_type , exc_val , exc_tb , file = excout )
279+ traceback .print_exception (exc_type , exc_val , exc_tb , file = excout , no_timestamp = True )
277280 return excout .getvalue ()
278281
279282# Override some StringIO methods.
@@ -1414,7 +1417,7 @@ def __run(self, test, compileflags, out):
14141417
14151418 # The example raised an exception: check if it was expected.
14161419 else :
1417- formatted_ex = traceback .format_exception_only (* exception [:2 ])
1420+ formatted_ex = traceback .format_exception_only (* exception [:2 ], no_timestamp = True )
14181421 if issubclass (exception [0 ], SyntaxError ):
14191422 # SyntaxError / IndentationError is special:
14201423 # we don't care about the carets / suggestions / etc
@@ -1749,6 +1752,15 @@ def check_output(self, want, got, optionflags):
17491752 if got == want :
17501753 return True
17511754
1755+ # This flag removes everything that looks like a timestamp as can
1756+ # be configured to display after exception messages in tracebacks.
1757+ # We're assuming nobody will ever write these in their 'want' docs
1758+ # as the feature is off by default, intended for production use.
1759+ if optionflags & IGNORE_EXCEPTION_TIMESTAMPS :
1760+ got = traceback .strip_exc_timestamps (got )
1761+ if got == want :
1762+ return True
1763+
17521764 # The ELLIPSIS flag says to let the sequence "..." in `want`
17531765 # match any substring in `got`.
17541766 if optionflags & ELLIPSIS :
0 commit comments