aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_base.py
diff options
context:
space:
mode:
authorGravatar mathsman5133 <[email protected]>2020-03-12 20:15:28 +1100
committerGravatar mathsman5133 <[email protected]>2020-03-12 20:15:28 +1100
commitf16d1bb143defd01cd988db007ed5a94b598c4ba (patch)
tree332d9dc042fc636ec9d3e91607620f2c5b762eec /tests/test_base.py
parentApply suggestions from Mark's code review. (diff)
parentMerge pull request #822 from python-discord/bug/mod/792/null-attachments (diff)
Merge branch 'master' of https://github.com/python-discord/bot into help-refactor
 Conflicts:  bot/cogs/help.py
Diffstat (limited to 'tests/test_base.py')
-rw-r--r--tests/test_base.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/tests/test_base.py b/tests/test_base.py
index a16e2af8f..a7db4bf3e 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -3,7 +3,11 @@ import unittest
import unittest.mock
-from tests.base import LoggingTestCase, _CaptureLogHandler
+from tests.base import LoggingTestsMixin, _CaptureLogHandler
+
+
+class LoggingTestCase(LoggingTestsMixin, unittest.TestCase):
+ pass
class LoggingTestCaseTests(unittest.TestCase):
@@ -18,24 +22,14 @@ class LoggingTestCaseTests(unittest.TestCase):
try:
with LoggingTestCase.assertNotLogs(self, level=logging.DEBUG):
pass
- except AssertionError:
+ except AssertionError: # pragma: no cover
self.fail("`self.assertNotLogs` raised an AssertionError when it should not!")
- @unittest.mock.patch("tests.base.LoggingTestCase.assertNotLogs")
- def test_the_test_function_assert_not_logs_does_not_raise_with_no_logs(self, assertNotLogs):
- """Test if test_assert_not_logs_does_not_raise_with_no_logs captures exception correctly."""
- assertNotLogs.return_value = iter([None])
- assertNotLogs.side_effect = AssertionError
-
- message = "`self.assertNotLogs` raised an AssertionError when it should not!"
- with self.assertRaises(AssertionError, msg=message):
- self.test_assert_not_logs_does_not_raise_with_no_logs()
-
def test_assert_not_logs_raises_correct_assertion_error_when_logs_are_emitted(self):
"""Test if LoggingTestCase.assertNotLogs raises AssertionError when logs were emitted."""
msg_regex = (
r"1 logs of DEBUG or higher were triggered on root:\n"
- r'<LogRecord: tests\.test_base, [\d]+, .+/tests/test_base\.py, [\d]+, "Log!">'
+ r'<LogRecord: tests\.test_base, [\d]+, .+[/\\]tests[/\\]test_base\.py, [\d]+, "Log!">'
)
with self.assertRaisesRegex(AssertionError, msg_regex):
with LoggingTestCase.assertNotLogs(self, level=logging.DEBUG):