def test_raise_error_without_mail(self): def func(): raise Exception('Foo') with self.assertRaises(Exception): utils.email_uncaught_exception(func)() self.assertEqual(len(mail.outbox), 0)
def test_raise_with_mail(self): def func(): raise Exception("Foo") with self.assertRaises(Exception): utils.email_uncaught_exception(func)() self.assertEqual(len(mail.outbox), 1)
def test_raise_with_mail(self): def func(): raise Exception('Foo') with self.assertRaises(Exception): utils.email_uncaught_exception(func)() self.assertEqual(len(mail.outbox), 1) error_mail = mail.outbox[0] self.assertEqual(['foo@bar'], error_mail.to) self.assertIn("Exception('Foo')", error_mail.subject) if django.VERSION >= (1, 7): self.assertIn("Exception('Foo')", error_mail.body)
def test_success(self): def func(): pass utils.email_uncaught_exception(func)
def test_success(self): def func(): pass utils.email_uncaught_exception(func) self.assertEqual(len(mail.outbox), 0)