Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
test_mattermost_importer: Condition html2text crash on Python version.
Anders Kaseorge216317f88c8
diff --git a/zerver/data_import/mattermost.py b/zerver/data_import/mattermost.pyindex b8d2b3dabff..c1d380e9f8f 100644--- a/zerver/data_import/mattermost.py+++ b/zerver/data_import/mattermost.py@@ -457,7 +457,7 @@ def process_raw_message_batch(try:content = convert_html_to_text(content)- except Exception:+ except Exception: # nocoveragelogging.warning("Error converting HTML to text for message: '%s'; continuing", content)logging.warning(str(raw_message))diff --git a/zerver/tests/test_mattermost_importer.py b/zerver/tests/test_mattermost_importer.pyindex 80f4ac7bb6a..1177cae0988 100644--- a/zerver/tests/test_mattermost_importer.py+++ b/zerver/tests/test_mattermost_importer.py@@ -1,5 +1,6 @@import filecmpimport os+import sysfrom typing import Anyfrom unittest.mock import call, patch@@ -705,9 +706,15 @@ class MatterMostImporter(ZulipTestCase):warn_log.output,["WARNING:root:Skipping importing direct message groups and DMs since there are multiple teams in the export",- # Check error log when trying to process a message with faulty HTML.- "WARNING:root:Error converting HTML to text for message: 'This will crash html2text!!! <g:brand><![CDATSALOMON NORTH AMERICA, IN}}]]></g:brand>'; continuing",- "WARNING:root:{'sender_id': 2, 'content': 'This will crash html2text!!! <g:brand><![CDATSALOMON NORTH AMERICA, IN}}]]></g:brand>', 'date_sent': 1553166657, 'reactions': [], 'channel_name': 'dumbledores-army'}",+ *(+ [+ # Check error log when trying to process a message with faulty HTML.+ "WARNING:root:Error converting HTML to text for message: 'This will crash html2text!!! <g:brand><![CDATSALOMON NORTH AMERICA, IN}}]]></g:brand>'; continuing",+ "WARNING:root:{'sender_id': 2, 'content': 'This will crash html2text!!! <g:brand><![CDATSALOMON NORTH AMERICA, IN}}]]></g:brand>', 'date_sent': 1553166657, 'reactions': [], 'channel_name': 'dumbledores-army'}",+ ]+ if sys.version_info < (3, 13)+ else []+ ),"WARNING:root:Skipping importing direct message groups and DMs since there are multiple teams in the export",],)@@ -955,8 +962,14 @@ class MatterMostImporter(ZulipTestCase):warn_log.output,["WARNING:root:Skipping importing direct message groups and DMs since there are multiple teams in the export",- "WARNING:root:Error converting HTML to text for message: 'Xxxx xxxx xxxxx xxxx2xxxx!!! <x:xxxxx><![XXXXXXXXXXX XXXXX XXXXXXX, XX}}]]></x:xxxxx>'; continuing",- "WARNING:root:{'sender_id': 2, 'content': 'Xxxx xxxx xxxxx xxxx2xxxx!!! <x:xxxxx><![XXXXXXXXXXX XXXXX XXXXXXX, XX}}]]></x:xxxxx>', 'date_sent': 1553166657, 'reactions': [], 'channel_name': 'dumbledores-army'}",+ *(+ [+ "WARNING:root:Error converting HTML to text for message: 'Xxxx xxxx xxxxx xxxx2xxxx!!! <x:xxxxx><![XXXXXXXXXXX XXXXX XXXXXXX, XX}}]]></x:xxxxx>'; continuing",+ "WARNING:root:{'sender_id': 2, 'content': 'Xxxx xxxx xxxxx xxxx2xxxx!!! <x:xxxxx><![XXXXXXXXXXX XXXXX XXXXXXX, XX}}]]></x:xxxxx>', 'date_sent': 1553166657, 'reactions': [], 'channel_name': 'dumbledores-army'}",+ ]+ if sys.version_info < (3, 13)+ else []+ ),"WARNING:root:Skipping importing direct message groups and DMs since there are multiple teams in the export",],)@@ -984,8 +997,14 @@ class MatterMostImporter(ZulipTestCase):warn_log.output,["WARNING:root:Skipping importing direct message groups and DMs since there are multiple teams in the export",- "WARNING:root:Error converting HTML to text for message: 'Xxxx xxxx xxxxx xxxx2xxxx!!! <x:xxxxx><![XXXXXXXXXXX XXXXX XXXXXXX, XX}}]]></x:xxxxx>'; continuing",- "WARNING:root:{'sender_id': 2, 'content': 'Xxxx xxxx xxxxx xxxx2xxxx!!! <x:xxxxx><![XXXXXXXXXXX XXXXX XXXXXXX, XX}}]]></x:xxxxx>', 'date_sent': 1553166657, 'reactions': [], 'channel_name': 'dumbledores-army'}",+ *(+ [+ "WARNING:root:Error converting HTML to text for message: 'Xxxx xxxx xxxxx xxxx2xxxx!!! <x:xxxxx><![XXXXXXXXXXX XXXXX XXXXXXX, XX}}]]></x:xxxxx>'; continuing",+ "WARNING:root:{'sender_id': 2, 'content': 'Xxxx xxxx xxxxx xxxx2xxxx!!! <x:xxxxx><![XXXXXXXXXXX XXXXX XXXXXXX, XX}}]]></x:xxxxx>', 'date_sent': 1553166657, 'reactions': [], 'channel_name': 'dumbledores-army'}",+ ]+ if sys.version_info < (3, 13)+ else []+ ),"WARNING:root:Skipping importing direct message groups and DMs since there are multiple teams in the export",],)