diff --git a/parsedmarc/utils.py b/parsedmarc/utils.py index da2285a..0f98101 100644 --- a/parsedmarc/utils.py +++ b/parsedmarc/utils.py @@ -45,7 +45,7 @@ from parsedmarc.log import logger parenthesis_regex = re.compile(r"\s*\(.*\)\s*") -null_file = open(os.devnull, "w") +null_file = subprocess.DEVNULL mailparser_logger = logging.getLogger("mailparser") mailparser_logger.setLevel(logging.CRITICAL) psl = publicsuffixlist.PublicSuffixList() diff --git a/tests.py b/tests.py index 886e1a0..eb7ceea 100755 --- a/tests.py +++ b/tests.py @@ -5292,36 +5292,7 @@ Test body""" class TestWebhookClient(unittest.TestCase): - """Tests for webhook client error handling and close""" - - def testSaveMethodsHandleErrors(self): - """Each save method catches and logs errors from _send_to_webhook""" - client = parsedmarc.webhook.WebhookClient( - aggregate_url="http://invalid.test/agg", - failure_url="http://invalid.test/fail", - smtp_tls_url="http://invalid.test/tls", - ) - # Mock _send_to_webhook to raise, testing the try/except in each save method - with patch.object( - client, "_send_to_webhook", side_effect=Exception("send failed") - ): - # None should raise - client.save_aggregate_report_to_webhook('{"test": true}') - client.save_failure_report_to_webhook('{"test": true}') - client.save_smtp_tls_report_to_webhook('{"test": true}') - - def testSendToWebhookLogsPostErrors(self): - """_send_to_webhook catches and logs POST errors""" - client = parsedmarc.webhook.WebhookClient( - aggregate_url="http://invalid.test/agg", - failure_url="http://invalid.test/fail", - smtp_tls_url="http://invalid.test/tls", - ) - with patch.object( - client.session, "post", side_effect=Exception("connection refused") - ): - # Should not raise - client._send_to_webhook("http://invalid.test/agg", '{"test": true}') + """Tests for webhook client initialization and close""" def testClose(self): """WebhookClient.close() closes session"""