Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect error message in Exception for pytest_terminal_summary #374

Open
sravantit25 opened this issue Mar 22, 2024 · 1 comment
Open

Comments

@sravantit25
Copy link
Collaborator

In conftest.py, for the pytest_terminal_summary method, the error message in the Exception talks specifically about 'email pytest report'.

    except Exception as e:
        print("Exception when trying to run test: %s"%__file__)
        print("Python says:%s"%str(e))
        solution = "It looks like you are trying to use email pytest report to run your test. \nPlease make sure you have updated .env with the right credentials ."

The error can be anything related to Slack, Email, Tesults, or Summary features. So, the error message must be more generic.

def pytest_terminal_summary(terminalreporter, exitstatus):
    "add additional section in terminal summary reporting."
    try:
        if not hasattr(terminalreporter.config, 'workerinput'):
            if  terminalreporter.config.getoption("--slack_flag").lower() == 'y':
                post_test_reports_to_slack.post_reports_to_slack()
            if terminalreporter.config.getoption("--email_pytest_report").lower() == 'y':
                #Initialize the Email_Pytest_Report object
                email_obj = Email_Pytest_Report()
                # Send html formatted email body message with pytest report as an attachment
                email_obj.send_test_report_email(html_body_flag=True,attachment_flag=True,report_file_path='default')
            if terminalreporter.config.getoption("--tesults").lower() == 'y':
                from utils import Tesults # pylint: disable=import-error,import-outside-toplevel
                Tesults.post_results_to_tesults()

    except Exception as e:
        print("Exception when trying to run test: %s"%__file__)
        print("Python says:%s"%str(e))
        solution = "It looks like you are trying to use email pytest report to run your test. \nPlease make sure you have updated .env with the right credentials ."
        print('\033[92m'+"\nSOLUTION: %s\n"%solution+'\033[0m')
Copy link

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant