diff options
author | Tomas R. <tomas.roun8@gmail.com> | 2025-01-15 01:48:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-14 16:48:46 -0800 |
commit | bd3baa8b1a7755f17b2fc98c7fb7b872fec43af3 (patch) | |
tree | e2e2695416dc415577405e786d7e3cc3ebe82370 /Lib/test/test_importlib/test_abc.py | |
parent | b52de22ac345ad8583bcc57f963e26b35c2ee527 (diff) | |
download | cpython-bd3baa8b1a7755f17b2fc98c7fb7b872fec43af3.tar.gz cpython-bd3baa8b1a7755f17b2fc98c7fb7b872fec43af3.zip |
gh-121604: Make sure all deprecated items in importlib raise DeprecationWarning (#128007)
Co-authored-by: rashansmith <smith.rashan@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Brett Cannon <brett@python.org>
Diffstat (limited to 'Lib/test/test_importlib/test_abc.py')
-rw-r--r-- | Lib/test/test_importlib/test_abc.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/test_abc.py b/Lib/test/test_importlib/test_abc.py index 603125f6d92..00af2dd7124 100644 --- a/Lib/test/test_importlib/test_abc.py +++ b/Lib/test/test_importlib/test_abc.py @@ -913,5 +913,37 @@ class SourceLoaderGetSourceTests: SourceOnlyLoaderMock=SPLIT_SOL) +class SourceLoaderDeprecationWarningsTests(unittest.TestCase): + """Tests SourceLoader deprecation warnings.""" + + def test_deprecated_path_mtime(self): + from importlib.abc import SourceLoader + class DummySourceLoader(SourceLoader): + def get_data(self, path): + return b'' + + def get_filename(self, fullname): + return 'foo.py' + + def path_stats(self, path): + return {'mtime': 1} + + loader = DummySourceLoader() + with self.assertWarns(DeprecationWarning): + loader.path_mtime('foo.py') + + +class ResourceLoaderDeprecationWarningsTests(unittest.TestCase): + """Tests ResourceLoader deprecation warnings.""" + + def test_deprecated_resource_loader(self): + from importlib.abc import ResourceLoader + class DummyLoader(ResourceLoader): + def get_data(self, path): + return b'' + + with self.assertWarns(DeprecationWarning): + DummyLoader() + if __name__ == '__main__': unittest.main() |