summaryrefslogtreecommitdiff
path: root/tests/test_apis.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_apis.py')
-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)