@@ -51,48 +51,14 @@ def match_text(self, text: str, sub_label: str = '') -> None:
5151
5252
5353def strip_tb_text (text : str ) -> str :
54- OFTO = '...omitted for tests only...'
55- #text = text.replace('\\\\', '\\') # for windows
56- #text = re.sub('.:\\\\', '/', text) # for windows
57- #text = text.replace('\\', '/') # for windows
58- #text = text.replace('\r', '') # for windows
59- #text = text.replace('WindowsPath', 'PosixPath') # for windows
60- #text = re.sub(r'\n[^\n]*\^\^\^[^\n]*\n', '\n', text)
61- # File "/usr/local/lib/python3.8/dist-packages/_pytest/_code/code.py", line 810, in repr_traceback_entry
62-
63- #text = re.sub(r'([^\w/.-])/[\w/.-]+(/[\w.-]+[^\w/.-])', fr'\1{OFTO}\2', text)
64- #text = re.sub(r'/[\w/.-]+(/[\w.-]+\.py[^\w/-])', fr'{OFTO}\1', text)
65-
66- #text = re.sub(r'(line)[^\n,]+(,)', fr'\1{OFTO}\2', text)
67- text = re .sub (r'(/argparse.py", line )[^\n,]+(,)' , fr'\1{ OFTO } \2' , text ) # argparse versions
68- #text = re.sub(r"(__file__ = )[^\n]*\n", fr"\1'{OFTO}'", text)
69- text = re .sub (r'( at 0x)\w+' , fr'\1{ OFTO } ' , text ) # object ids
70- #text = re.sub(r'(__builtins__[^{]*{)[^\n]*', fr'\1{OFTO}', text)
71- #text = re.sub(r'(<ipython-input-)\d+-\w+(>)', fr'{OFTO}', text)
72- text = re .sub (r'<ipython-input-[^>]+>' , OFTO , text ) # jupyter cells on some versions
73- text = re .sub (r'(")[\w/.-]+/[\d]+.py(")' , fr'\1{ OFTO } \2' , text ) # jupyter cells on some versions
74- text = re .sub (r'/[\w/.-]+(/[\w.-]+\.py[^\w/-])' , fr'{ OFTO } \1' , text ) # machine-dependent paths
54+ OFTO = '...omitted for tests only, '
55+
56+ text = re .sub (r'(/argparse.py", line )[^\n,]+(,)' , fr'\1{ OFTO } argparse internals...\2' , text ) # argparse versions
57+ text = re .sub (r'( at 0x)\w+' , fr'\1{ OFTO } obj id...' , text ) # object ids
58+ text = re .sub (r'<ipython-input-[^>]+>' , f'{ OFTO } jupyter cell...' , text ) # jupyter cells on some versions
59+ text = re .sub (r'(")[\w/.-]+/[\d]+.py(")' , fr'\1{ OFTO } jupyter code...\2' , text ) # jupyter cells on some versions
60+ text = re .sub (r'/[\w/.-]+(/[\w.-]+\.py[^\w/-])' , fr'{ OFTO } abs path...\1' , text ) # machine-dependent paths
7561 text = re .sub ('\n [^\n ]+function open[^\n ]+\n ' , '\n ' , text ) # Jupyter versions?
76- #text = re.sub('\n[^\n]+_pytest[^\n]+\n', '\n', text)
77- #text = re.sub(', required=True', '', text)
78- #text = re.sub('integer division or modulo', 'division', text)
79- #text = re.sub('\n[^\n]*__annotations__[^\n]*\n', '\n', text)
80- #text = re.sub('\n[^\n]*return self._parse_known_args2(args, namespace, intermixed=False)[^\n]*\n', '\n', text)
81- #text = re.sub(' 23 vars', ' 22 vars', text)
82- #text = re.sub(' 10 vars', ' 9 vars', text)
83- #for p in ['server.py', 'code.py', 'main.py']:
84- # text = re.sub(p + ': error:', 'python3 -m traceback_with_variables.main: error:', text)
85- # text = re.sub('usage: ' + p, 'usage: python3 -m traceback_with_variables.main', text)
86- # text = re.sub("prog='" + p, "prog='python3 -m traceback_with_variables.main", text)
87- # text = re.sub("'prog': '" + p, "'prog': 'python3 -m traceback_with_variables.main", text)
88-
89- #text = re.sub('main.py', 'python3 -m traceback_with_variables.main', text)
90- #text = re.sub('server.py', 'python3 -m traceback_with_variables.main', text)
91- #text = re.sub('code.py', 'python3 -m traceback_with_variables.main', text)
92- #text = re.sub(r'(<_froze?n?s?e?t? ?a?t? ?0?x?).*(>)', fr'\1{OFTO}\2', text)
93- #text = re.sub(r'(<trace?b?a?c?k? ?a?t? ?0?x?).*(>)', fr'\1{OFTO}\2', text)
94- #text = re.sub(r'(<func?t?i?o?n? ?a?t? ?0?x?).*(>)', fr'\1{OFTO}\2', text)
95- #text = re.sub(r'\n\s+~*\^+\n', '\n', text) # for jupyter with py>=3.13
9662
9763 return text
9864
0 commit comments