django-mailer icon indicating copy to clipboard operation
django-mailer copied to clipboard

use unittest.mock instead of mock

Open pgajdos opened this issue 3 years ago • 2 comments

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 avatar May 09 '22 15:05 pgajdos

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

pgajdos avatar May 09 '22 15:05 pgajdos

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.

jaap3 avatar Jun 19 '23 08:06 jaap3