pinax / django-mailer

mail queuing and management for the Django web framework
MIT License
811 stars 336 forks source link

use unittest.mock instead of mock #157

Open pgajdos opened 2 years ago

pgajdos commented 2 years ago

Could you please consider to use unittest.mock instead of mock as a fallback? You seem to support older python versions, so you probably cannot really get rid of it completely for now.

https://trello.com/c/S6eADbii/64-remove-python-mock https://fedoraproject.org/wiki/Changes/DeprecatePythonMock

pgajdos commented 2 years ago

At least for 3.8, 3.9 and 3.10 following works for me:

--- django-mailer-2.2.orig/tests/test_mailer.py 2022-05-09 17:23:15.968311514 +0200
+++ django-mailer-2.2/tests/test_mailer.py  2022-05-09 17:23:15.976311564 +0200
@@ -12,7 +12,7 @@ from django.core.exceptions import Impro
 from django.core.management import call_command
 from django.test import TestCase
 from django.utils.timezone import now as datetime_now
-from mock import Mock, patch
+from unittest.mock import Mock, patch
 import six

 import mailer
jaap3 commented 1 year ago

Older python versions were recently removed from the tests matrix, so a PR that uses unittest.mock instead of the mock library should now be feasible.