Permalink
Browse files

remove specific code for Python2.5 in the tests

  • Loading branch information...
1 parent d0f0707 commit 56a582c56d9ed66ea695fb5dbcdc03fc43f0a35c @Fantomas42 committed Apr 8, 2013
Showing with 28 additions and 48 deletions.
  1. +3 −7 zinnia/tests/entry.py
  2. +13 −21 zinnia/tests/spam_checker.py
  3. +12 −20 zinnia/tests/url_shortener.py
View
@@ -317,13 +317,9 @@ def test_get_entry_base_model(self):
self.assertEquals(get_entry_base_model(), EntryAbstractClass)
entry.ENTRY_BASE_MODEL = 'mymodule.myclass'
- try:
- with warnings.catch_warnings(record=True) as w:
- self.assertEquals(get_entry_base_model(), EntryAbstractClass)
- self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
- except AttributeError:
- # Fail under Python2.5, because of'warnings.catch_warnings'
- pass
+ with warnings.catch_warnings(record=True) as w:
+ self.assertEquals(get_entry_base_model(), EntryAbstractClass)
+ self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
entry.ENTRY_BASE_MODEL = 'zinnia.models.entry.EntryAbstractClass'
self.assertEquals(get_entry_base_model(), EntryAbstractClass)
@@ -11,28 +11,20 @@ class SpamCheckerTestCase(TestCase):
"""Test cases for zinnia.spam_checker"""
def test_get_spam_checker(self):
- try:
- with warnings.catch_warnings(record=True) as w:
- self.assertEquals(get_spam_checker('mymodule.myclass'), None)
- self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
- self.assertEquals(
- str(w[-1].message),
- 'mymodule.myclass backend cannot be imported')
- except AttributeError:
- # Fail under Python2.5, because of'warnings.catch_warnings'
- pass
+ with warnings.catch_warnings(record=True) as w:
+ self.assertEquals(get_spam_checker('mymodule.myclass'), None)
+ self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
+ self.assertEquals(
+ str(w[-1].message),
+ 'mymodule.myclass backend cannot be imported')
- try:
- with warnings.catch_warnings(record=True) as w:
- self.assertEquals(
- get_spam_checker('zinnia.tests.custom_spam_checker'), None)
- self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
- self.assertEquals(
- str(w[-1].message),
- 'This backend only exists for testing')
- except AttributeError:
- # Fail under Python2.5, because of'warnings.catch_warnings'
- pass
+ with warnings.catch_warnings(record=True) as w:
+ self.assertEquals(
+ get_spam_checker('zinnia.tests.custom_spam_checker'), None)
+ self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
+ self.assertEquals(
+ str(w[-1].message),
+ 'This backend only exists for testing')
self.assertEquals(
get_spam_checker('zinnia.spam_checker.backends.all_is_spam'),
@@ -19,28 +19,20 @@ def tearDown(self):
def test_get_url_shortener(self):
us_settings.URL_SHORTENER_BACKEND = 'mymodule.myclass'
- try:
- with warnings.catch_warnings(record=True) as w:
- self.assertEquals(get_url_shortener(), default_backend)
- self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
- self.assertEquals(
- str(w[-1].message),
- 'mymodule.myclass backend cannot be imported')
- except AttributeError:
- # Fail under Python2.5, because of'warnings.catch_warnings'
- pass
+ with warnings.catch_warnings(record=True) as w:
+ self.assertEquals(get_url_shortener(), default_backend)
+ self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
+ self.assertEquals(
+ str(w[-1].message),
+ 'mymodule.myclass backend cannot be imported')
us_settings.URL_SHORTENER_BACKEND = 'zinnia.tests.custom_url_shortener'
- try:
- with warnings.catch_warnings(record=True) as w:
- self.assertEquals(get_url_shortener(), default_backend)
- self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
- self.assertEquals(
- str(w[-1].message),
- 'This backend only exists for testing')
- except AttributeError:
- # Fail under Python2.5, because of'warnings.catch_warnings'
- pass
+ with warnings.catch_warnings(record=True) as w:
+ self.assertEquals(get_url_shortener(), default_backend)
+ self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
+ self.assertEquals(
+ str(w[-1].message),
+ 'This backend only exists for testing')
us_settings.URL_SHORTENER_BACKEND = 'zinnia.url_shortener'\
'.backends.default'

0 comments on commit 56a582c

Please sign in to comment.