0

I have written django tests to check my outbox emails as shown below

class TestX(TestCase):
    def setUp(self):
        # Clear outbox.
        mail.outbox.clear()
        super().setUp()

    def tearDown(self):
        # Clear outbox.
        mail.outbox.clear()
        super().tearDown()

however, performing assertions e.g self.assertEqual(len(mail.outbox), 1) fails with the len(mail.outbox) showing a large number as compared to the emails I've sent using send mail. I know there are other apps also sending emails so I'm wondering if the emails are being sent in parallel and thus my clear isn't effective or what might be the issue?

E_K
  • 2,159
  • 23
  • 39
  • How could we know that? What is the `mail` object? How does it get set up? – Tim Roberts Dec 20 '22 at 04:39
  • 1
    By specifying it's django tests I inferred it's a django object but here it is https://docs.djangoproject.com/en/4.1/topics/testing/tools/#email-services – E_K Dec 20 '22 at 06:17

0 Answers0