def pytest_configure()

in conftest.py [0:0]


def pytest_configure(config):
    # Check if run is "reportable": if it is on a never-reported Fx version
    if os.environ.get("TESTRAIL_REPORT"):
        logging.warning("Checking to see if session would be reportable...")
        if os.environ.get("TASKCLUSTER_ROOT_URL") and os.environ.get("FX_EXECUTABLE"):
            logging.warning("Getting TC credentials...")
            creds = get_tc_secret()
            if creds:
                os.environ["TESTRAIL_USERNAME"] = creds.get("TESTRAIL_USERNAME")
                os.environ["TESTRAIL_API_KEY"] = creds.get("TESTRAIL_API_KEY")
                os.environ["TESTRAIL_BASE_URL"] = creds.get("TESTRAIL_BASE_URL")
            elif not os.environ.get("TESTRAIL_USERNAME"):
                logging.error(
                    "Attempted to log into TestRail, but could not find credentials."
                )
                raise OSError("Could not find TestRail credentials")

        if not tri.reportable():
            pytest.exit("Test run is not reportable. Exiting.")