[Answered ]-How to send an email on successful test completion in django

2👍

import subprocess
ret = subprocess.call(['python', 'manage.py', 'test'])
if ret == 0:
    print("Tests Passed Successfully")
else:
    print("Tests failed")
👤nwk

0👍

You could simply write another Python script to generate and send the email(s).

#!/bin/bash
TEST_RESULT=`python manage.py test`
rc=$?;
if [[ $rc -eq 0 ]]
then
    python sendemail.py Success
else
    python sendemail.py Failure
fi

See the email documentation: https://docs.python.org/3/library/email-examples.html

Leave a comment