summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2022-04-28 12:31:18 +0100
committerStephen Finucane <stephen@that.guru>2022-10-19 11:50:33 +0100
commitf0376a18496f2707f41a028882a500b83192b8d0 (patch)
tree4924c36390c34218d577fadfe6670d403184a575
parentd303d552579b9749433d8d8380ff799880721fae (diff)
downloadfixtures-git-f0376a18496f2707f41a028882a500b83192b8d0.tar.gz
tests: Run 'warnings' tests
These were never added to the list of filtered modules, meaning they never actually ran. Correct that and fix the failures, which were caused by DeprecationWarning being disabled by default in Python 3.2 onwards. Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
-rw-r--r--fixtures/testcase.py2
-rw-r--r--fixtures/tests/_fixtures/__init__.py7
-rw-r--r--fixtures/tests/_fixtures/test_warnings.py12
-rw-r--r--tox.ini2
4 files changed, 18 insertions, 5 deletions
diff --git a/fixtures/testcase.py b/fixtures/testcase.py
index 1d6a85c..d7999f3 100644
--- a/fixtures/testcase.py
+++ b/fixtures/testcase.py
@@ -24,7 +24,7 @@ from fixtures.fixture import gather_details
class TestWithFixtures(unittest.TestCase):
"""A TestCase with a helper function to use fixtures.
-
+
Normally used as a mix-in class to add useFixture.
Note that test classes such as testtools.TestCase which already have a
diff --git a/fixtures/tests/_fixtures/__init__.py b/fixtures/tests/_fixtures/__init__.py
index 1b4c359..b76244a 100644
--- a/fixtures/tests/_fixtures/__init__.py
+++ b/fixtures/tests/_fixtures/__init__.py
@@ -1,12 +1,12 @@
# fixtures: Fixtures with cleanups for testing and convenience.
#
# Copyright (c) 2010, Robert Collins <robertc@robertcollins.net>
-#
+#
# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
# license at the users choice. A copy of both licenses are available in the
# project source as Apache-2.0 and BSD. You may not use this file except in
# compliance with one of these two licences.
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -27,7 +27,8 @@ def load_tests(loader, standard_tests, pattern):
'tempdir',
'temphomedir',
'timeout',
- ]
+ 'warnings',
+ ]
prefix = "fixtures.tests._fixtures.test_"
test_mod_names = [prefix + test_module for test_module in test_modules]
standard_tests.addTests(loader.loadTestsFromNames(test_mod_names))
diff --git a/fixtures/tests/_fixtures/test_warnings.py b/fixtures/tests/_fixtures/test_warnings.py
index 4731626..c9e68bf 100644
--- a/fixtures/tests/_fixtures/test_warnings.py
+++ b/fixtures/tests/_fixtures/test_warnings.py
@@ -21,6 +21,10 @@ import fixtures
class TestWarnings(testtools.TestCase, fixtures.TestWithFixtures):
def test_capture_reuse(self):
+ # DeprecationWarnings are hidden by default in Python 3.2+, enable them
+ # https://docs.python.org/3/library/warnings.html#default-warning-filter
+ warnings.simplefilter("always")
+
w = fixtures.WarningsCapture()
with w:
warnings.warn("test", DeprecationWarning)
@@ -29,12 +33,20 @@ class TestWarnings(testtools.TestCase, fixtures.TestWithFixtures):
self.assertEqual([], w.captures)
def test_capture_message(self):
+ # DeprecationWarnings are hidden by default in Python 3.2+, enable them
+ # https://docs.python.org/3/library/warnings.html#default-warning-filter
+ warnings.simplefilter("always")
+
w = self.useFixture(fixtures.WarningsCapture())
warnings.warn("hi", DeprecationWarning)
self.assertEqual(1, len(w.captures))
self.assertEqual("hi", str(w.captures[0].message))
def test_capture_category(self):
+ # DeprecationWarnings are hidden by default in Python 3.2+, enable them
+ # https://docs.python.org/3/library/warnings.html#default-warning-filter
+ warnings.simplefilter("always")
+
w = self.useFixture(fixtures.WarningsCapture())
categories = [
DeprecationWarning, Warning, UserWarning,
diff --git a/tox.ini b/tox.ini
index a7e5ded..6e22ff7 100644
--- a/tox.ini
+++ b/tox.ini
@@ -7,4 +7,4 @@ usedevelop = true
extras =
docs
test
-commands = python -m testtools.run fixtures.test_suite
+commands = python -m testtools.run fixtures.test_suite {posargs}