Substitute hex numbers in title and comments by a token (#56)

This commit is contained in:
Ayush Shridhar 2019-01-17 21:20:46 +05:30 коммит произвёл Marco
Родитель f0bc25ddd6
Коммит 17a648f6e6
2 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -134,6 +134,10 @@ def cleanup_fileref(text):
return re.sub(r'\w+\.py\b|\w+\.json\b|\w+\.js\b|\w+\.jsm\b|\w+\.html\b|\w+\.css\b|\w+\.c\b|\w+\.cpp\b|\w+\.h\b', '__FILE_REFERENCE__', text)
def cleanup_hex(text):
return re.sub(r'\b0[xX][0-9a-fA-F]+\b', '__HEX_NUMBER__', text)
def cleanup_dll(text):
return re.sub(r'\w+\.dll\b', '__DLL_NAME__', text)

Просмотреть файл

@ -25,6 +25,15 @@ def test_cleanup_fileref():
assert bug_features.cleanup_fileref(orig_text) == cleaned_text
def test_cleanup_hex():
tests = [
('0 scdetour.dll scdetour.dll@0x2dd77', '0 scdetour.dll scdetour.dll@__HEX_NUMBER__'),
('Some examples of hex numbers are 0x227c2 or 0x3fA2', 'Some examples of hex numbers are __HEX_NUMBER__ or __HEX_NUMBER__')
]
for orig_text, cleaned_text in tests:
assert bug_features.cleanup_hex(orig_text) == cleaned_text
def test_cleanup_dll():
tests = [
('Crashing thread: 0 scdetour.dll scdetour.dll@0x2dd77', 'Crashing thread: 0 __DLL_NAME__ __DLL_NAME__@0x2dd77'),