summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2022-05-27 09:13:09 -0400
committerGitHub <noreply@github.com>2022-05-27 09:13:09 -0400
commita767b2daaad78ba32d45a4f1dabb7c5e218f030a (patch)
tree0a395d3751ed27fdbebc1c64a565384e5048b3cb /tests
parentdc434df776fe9af36fe07c4e782e51035ce30e1f (diff)
downloadpython-markdown-a767b2daaad78ba32d45a4f1dabb7c5e218f030a.tar.gz
Remove previously deprecated objects
This completely removes all objects which were deprecated in version 3.0 (this change will be included in version 3.4). Given the time that has passed, and the fact that older unmaintained extensions are not likely to support the new minimum Python version, this is little concern about breaking older extensions.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_apis.py114
1 files changed, 4 insertions, 110 deletions
diff --git a/tests/test_apis.py b/tests/test_apis.py
index efdc383..1a38be6 100644
--- a/tests/test_apis.py
+++ b/tests/test_apis.py
@@ -316,50 +316,16 @@ class RegistryTests(unittest.TestCase):
r = markdown.util.Registry()
with self.assertRaises(TypeError):
r[0] = 'a'
- # TODO: restore this when deprecated __setitem__ is removed.
- # with self.assertRaises(TypeError):
- # r['a'] = 'a'
- # TODO: remove this when deprecated __setitem__ is removed.
- with warnings.catch_warnings(record=True) as w:
- warnings.simplefilter("always")
-
- r['a'] = Item('a')
- self.assertEqual(list(r), ['a'])
- r['b'] = Item('b')
- self.assertEqual(list(r), ['a', 'b'])
- r['a'] = Item('a1')
- self.assertEqual(list(r), ['a1', 'b'])
-
- # Check the warnings
- self.assertEqual(len(w), 3)
- self.assertTrue(all(issubclass(x.category, DeprecationWarning) for x in w))
+ with self.assertRaises(TypeError):
+ r['a'] = 'a'
def testRegistryDelItem(self):
r = markdown.util.Registry()
r.register(Item('a'), 'a', 20)
- with self.assertRaises(KeyError):
+ with self.assertRaises(TypeError):
del r[0]
- # TODO: restore this when deprecated __del__ is removed.
- # with self.assertRaises(TypeError):
- # del r['a']
- # TODO: remove this when deprecated __del__ is removed.
- with warnings.catch_warnings(record=True) as w:
- warnings.simplefilter("always")
-
- r.register(Item('b'), 'b', 15)
- r.register(Item('c'), 'c', 10)
- del r['b']
- self.assertEqual(list(r), ['a', 'c'])
+ with self.assertRaises(TypeError):
del r['a']
- self.assertEqual(list(r), ['c'])
- with self.assertRaises(KeyError):
- del r['badname']
- del r['c']
- self.assertEqual(list(r), [])
-
- # Check the warnings
- self.assertEqual(len(w), 4)
- self.assertTrue(all(issubclass(x.category, DeprecationWarning) for x in w))
def testRegistrySlice(self):
r = markdown.util.Registry()
@@ -390,39 +356,6 @@ class RegistryTests(unittest.TestCase):
self.assertEqual(len(r), 2)
self.assertEqual(list(r), ['b2', 'a'])
- def testRegistryDeprecatedAdd(self):
- with warnings.catch_warnings(record=True) as w:
- warnings.simplefilter("always")
-
- r = markdown.util.Registry()
- # Add first item
- r.add('c', Item('c'), '_begin')
- self.assertEqual(list(r), ['c'])
- # Added to beginning
- r.add('b', Item('b'), '_begin')
- self.assertEqual(list(r), ['b', 'c'])
- # Add before first item
- r.add('a', Item('a'), '<b')
- self.assertEqual(list(r), ['a', 'b', 'c'])
- # Add before non-first item
- r.add('a1', Item('a1'), '<b')
- self.assertEqual(list(r), ['a', 'a1', 'b', 'c'])
- # Add after non-last item
- r.add('b1', Item('b1'), '>b')
- self.assertEqual(list(r), ['a', 'a1', 'b', 'b1', 'c'])
- # Add after last item
- r.add('d', Item('d'), '>c')
- self.assertEqual(list(r), ['a', 'a1', 'b', 'b1', 'c', 'd'])
- # Add to end
- r.add('e', Item('e'), '_end')
- self.assertEqual(list(r), ['a', 'a1', 'b', 'b1', 'c', 'd', 'e'])
- with self.assertRaises(ValueError):
- r.add('f', Item('f'), 'badlocation')
-
- # Check the warnings
- self.assertEqual(len(w), 8)
- self.assertTrue(all(issubclass(x.category, DeprecationWarning) for x in w))
-
class TestErrors(unittest.TestCase):
""" Test Error Reporting. """
@@ -1022,42 +955,3 @@ Some +test+ and a [+link+](http://test.com)
self.md.reset()
self.assertEqual(self.md.convert(test), result)
-
-
-class TestGeneralDeprecations(unittest.TestCase):
- """Test general deprecations."""
-
- def test_version_deprecation(self):
- """Test that version is deprecated."""
-
- with warnings.catch_warnings(record=True) as w:
- # Cause all warnings to always be triggered.
- warnings.simplefilter("always")
- # Trigger a warning.
- version = markdown.version
- # Verify some things
- self.assertEqual(len(w), 1)
- self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
- self.assertEqual(version, markdown.__version__)
-
- def test_version_info_deprecation(self):
- """Test that version info is deprecated."""
-
- with warnings.catch_warnings(record=True) as w:
- # Cause all warnings to always be triggered.
- warnings.simplefilter("always")
- # Trigger a warning.
- version_info = markdown.version_info
- # Verify some things
- self.assertEqual(len(w), 1)
- self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
- self.assertEqual(version_info, markdown.__version_info__)
-
- def test_deprecation_wrapper_dir(self):
- """Tests the `__dir__` attribute of the class as it replaces the module's."""
-
- dir_attr = dir(markdown)
- self.assertNotIn('version', dir_attr)
- self.assertIn('__version__', dir_attr)
- self.assertNotIn('version_info', dir_attr)
- self.assertIn('__version_info__', dir_attr)