diff options
author | Jelmer Vernooij <jelmer@jelmer.uk> | 2022-10-19 13:04:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-19 13:04:19 +0200 |
commit | f9c6653afff17951cd0523a1fe100754d37af50a (patch) | |
tree | 98972276e3e3a2e79620c473bc405d5a9ef80517 | |
parent | d303d552579b9749433d8d8380ff799880721fae (diff) | |
parent | 168f83c76119468948b6371cefec58d527c15510 (diff) | |
download | fixtures-git-f9c6653afff17951cd0523a1fe100754d37af50a.tar.gz |
Merge pull request #75 from stephenfin/explore-tests
Replace hardcoded list of tests
-rw-r--r-- | fixtures/testcase.py | 2 | ||||
-rw-r--r-- | fixtures/tests/_fixtures/__init__.py | 26 | ||||
-rw-r--r-- | fixtures/tests/_fixtures/test_warnings.py | 12 | ||||
-rw-r--r-- | tox.ini | 2 |
4 files changed, 24 insertions, 18 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..b2a33ef 100644 --- a/fixtures/tests/_fixtures/__init__.py +++ b/fixtures/tests/_fixtures/__init__.py @@ -1,34 +1,28 @@ # 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 # license you chose for the specific language governing permissions and # limitations under that license. +import os + + def load_tests(loader, standard_tests, pattern): test_modules = [ - 'environ', - 'logger', - 'mockpatch', - 'monkeypatch', - 'packagepath', - 'popen', - 'pythonpackage', - 'pythonpath', - 'streams', - 'tempdir', - 'temphomedir', - 'timeout', - ] - prefix = "fixtures.tests._fixtures.test_" + os.path.splitext(path)[0] + for path in os.listdir(os.path.dirname(__file__)) + if path.startswith('test_') + ] + prefix = "fixtures.tests._fixtures." test_mod_names = [prefix + test_module for test_module in test_modules] standard_tests.addTests(loader.loadTestsFromNames(test_mod_names)) return standard_tests 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, @@ -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} |