User-supplied arguments and the EMAIL_SUBJECT_PREFIX setting are used to compose the email subject (#16736).
(self)
| 323 | EMAIL_SUBJECT_PREFIX="-SuperAwesomeSubject-", |
| 324 | ) |
| 325 | def test_accepts_args(self): |
| 326 | """ |
| 327 | User-supplied arguments and the EMAIL_SUBJECT_PREFIX setting are used |
| 328 | to compose the email subject (#16736). |
| 329 | """ |
| 330 | message = "Custom message that says '%s' and '%s'" |
| 331 | token1 = "ping" |
| 332 | token2 = "pong" |
| 333 | |
| 334 | admin_email_handler = self.get_admin_email_handler(self.logger) |
| 335 | # Backup then override original filters |
| 336 | orig_filters = admin_email_handler.filters |
| 337 | try: |
| 338 | admin_email_handler.filters = [] |
| 339 | |
| 340 | self.logger.error(message, token1, token2) |
| 341 | |
| 342 | self.assertEqual(len(mail.outbox), 1) |
| 343 | self.assertEqual(mail.outbox[0].to, ["admin@example.com"]) |
| 344 | self.assertEqual( |
| 345 | mail.outbox[0].subject, |
| 346 | "-SuperAwesomeSubject-ERROR: " |
| 347 | "Custom message that says 'ping' and 'pong'", |
| 348 | ) |
| 349 | finally: |
| 350 | # Restore original filters |
| 351 | admin_email_handler.filters = orig_filters |
| 352 | |
| 353 | @override_settings( |
| 354 | ADMINS=["admin@example.com"], |
nothing calls this directly
no test coverage detected