aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--azure-pipelines.yml7
-rw-r--r--tests/base.py3
-rw-r--r--tests/test_base.py32
3 files changed, 31 insertions, 11 deletions
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 3d0932398..15470f9be 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -43,13 +43,6 @@ jobs:
codeCoverageTool: Cobertura
summaryFileLocation: coverage.xml
- - task: PublishTestResults@2
- displayName: 'Publish Test Results'
- condition: succeededOrFailed()
- inputs:
- testResultsFiles: junit.xml
- testRunTitle: 'Bot Test results'
-
- job: build
displayName: 'Build & Push Container'
dependsOn: 'test'
diff --git a/tests/base.py b/tests/base.py
index 625dcc0a8..029a249ed 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -12,9 +12,6 @@ class _CaptureLogHandler(logging.Handler):
super().__init__()
self.records = []
- def flush(self):
- pass
-
def emit(self, record):
self.records.append(record)
diff --git a/tests/test_base.py b/tests/test_base.py
index b7c1e0037..a16e2af8f 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -3,7 +3,7 @@ import unittest
import unittest.mock
-from tests.base import LoggingTestCase
+from tests.base import LoggingTestCase, _CaptureLogHandler
class LoggingTestCaseTests(unittest.TestCase):
@@ -59,3 +59,33 @@ class LoggingTestCaseTests(unittest.TestCase):
self.assertEqual(self.log.handlers, old_handlers)
self.assertEqual(self.log.level, old_level)
self.assertEqual(self.log.propagate, old_propagate)
+
+ def test_logging_test_case_works_with_logger_instance(self):
+ """Test if the LoggingTestCase captures logging for provided logger."""
+ log = logging.getLogger("new_logger")
+ with self.assertRaises(AssertionError):
+ with LoggingTestCase.assertNotLogs(self, logger=log):
+ log.info("Hello, this should raise an AssertionError")
+
+ def test_logging_test_case_respects_alternative_logger(self):
+ """Test if LoggingTestCase only checks the provided logger."""
+ log_one = logging.getLogger("log one")
+ log_two = logging.getLogger("log two")
+ with LoggingTestCase.assertNotLogs(self, logger=log_one):
+ log_two.info("Hello, this should not raise an AssertionError")
+
+ def test_logging_test_case_respects_logging_level(self):
+ """Test if LoggingTestCase does not raise for a logging level lower than provided."""
+ with LoggingTestCase.assertNotLogs(self, level=logging.CRITICAL):
+ self.log.info("Hello, this should raise an AssertionError")
+
+ def test_capture_log_handler_default_initialization(self):
+ """Test if the _CaptureLogHandler is initialized properly."""
+ handler = _CaptureLogHandler()
+ self.assertFalse(handler.records)
+
+ def test_capture_log_handler_saves_record_on_emit(self):
+ """Test if the _CaptureLogHandler saves the log record when it's emitted."""
+ handler = _CaptureLogHandler()
+ handler.emit("Log message")
+ self.assertIn("Log message", handler.records)