From 7e2fc7d354b46b87e7edf4ddb50928d53320d5cd Mon Sep 17 00:00:00 2001 From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com> Date: Wed, 7 Aug 2024 17:10:26 +0000 Subject: [PATCH] Add groups on testname for ease of ci debug --- bert_e/tests/test_bert_e.py | 14 +++++++++++++- tox.ini | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bert_e/tests/test_bert_e.py b/bert_e/tests/test_bert_e.py index c7f597ee..72b5cfde 100644 --- a/bert_e/tests/test_bert_e.py +++ b/bert_e/tests/test_bert_e.py @@ -26,6 +26,7 @@ from unittest.mock import Mock from unittest.mock import patch from urllib.parse import quote_plus +from os import getenv import requests import requests_mock @@ -90,6 +91,9 @@ """ # noqa +log = logging.getLogger(__name__) + + def initialize_git_repo(repo, username, usermail): """resets the git repo""" assert '/ring/' not in repo._url # This is a security, do not remove @@ -825,6 +829,10 @@ def bypass_all_but(self, exceptions): def setUp(self): warnings.resetwarnings() warnings.simplefilter('ignore') + self.ci: bool = bool(getenv('CI', False)) + if self.ci: + # print a group with the test name that is about to run + log.info(f"::group::{self._testMethodName}") self.admin_id = None self.contributor_id = None # repo creator and reviewer @@ -889,6 +897,9 @@ def tearDown(self): self.admin_bb.delete() self.gitrepo.delete() + if self.ci: + # end the group with the test name that just ran + log.info("::endgroup::") def create_pr( self, @@ -7743,7 +7754,8 @@ def main(): jira_api.JiraIssue = jira_api_mock.JiraIssue if RepositoryTests.args.verbose: - logging.basicConfig(level=logging.DEBUG) + # only the message in the format string will be displayed + logging.basicConfig(level=logging.DEBUG, format="%(message)s") else: # it is expected that Bert-E issues some warning # during the tests, only report critical stuff diff --git a/tox.ini b/tox.ini index 5636c105..43fae19f 100644 --- a/tox.ini +++ b/tox.ini @@ -30,6 +30,7 @@ commands = coverage run -am bert_e.tests.test_server [testenv:tests-noqueue] deps = pip==22.3.1 +passenv = CI commands = coverage run -am bert_e.tests.test_bert_e \ -v \ @@ -48,6 +49,7 @@ commands = [testenv:tests] deps = pip==22.3.1 +passenv = CI commands = coverage run -am bert_e.tests.test_bert_e \ -v \