Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix error log test
Browse files Browse the repository at this point in the history
zargot committed Dec 11, 2023

Verified

This commit was signed with the committer’s verified signature.
hediet Henning Dieterichs
1 parent 0dd6d5d commit d8fc423
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/common.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
package modules.
"""

import logging
import os
import sys
import unittest
@@ -17,11 +18,15 @@


class OdmTestCase(unittest.TestCase):
# FIXME
# def run(self, result=None):
# # makes sure that tests fails when errors are logged
# with self.assertNoLogs(None, 'ERROR'):
# super().run(result)
def run(self, result=None):
# This makes sure that tests fails when errors are logged.
# XXX: assertNoLogs is not available in python < 3.10, so we need to do
# an inverse check with assertLogs.
single_entry = 'ERROR:root:this is the only valid error log entry'
with self.assertLogs(None, logging.ERROR) as cm:
super().run(result)
logging.error(single_entry)
self.assertTrue([single_entry], cm.output)

def assertReportEqual(self, expected, report):
self.assertEqual(expected['errors'], report.errors)

0 comments on commit d8fc423

Please sign in to comment.