1
0
Fork 0
forked from github/pelican

Merge pull request #1850 from ingwinlu/deprecation_warnings

Make Pelican Python 3.5 compatible
This commit is contained in:
Justin Mayer 2015-11-03 07:22:12 -08:00
commit 880ba20a98
8 changed files with 83 additions and 11 deletions

View file

@ -1,2 +1,15 @@
import logging
import warnings
from pelican.log import log_warnings
# redirect warnings modulole to use logging instead
log_warnings()
# setup warnings to log DeprecationWarning's and error on
# warnings in pelican's codebase
warnings.simplefilter("default", DeprecationWarning)
warnings.filterwarnings("error", ".*", Warning, "pelican")
# Add a NullHandler to silence warning about no available handlers
logging.getLogger().addHandler(logging.NullHandler())

View file

@ -3,6 +3,8 @@ from __future__ import print_function, unicode_literals
import os
import six
from pelican import readers
from pelican.tests.support import get_settings, unittest
from pelican.utils import SafeDatetime
@ -55,7 +57,8 @@ class TestAssertDictHasSubset(ReaderTest):
self.assertDictHasSubset(self.dictionary, self.dictionary)
def test_fail_not_set(self):
self.assertRaisesRegexp(
six.assertRaisesRegex(
self,
AssertionError,
'Expected.*key-c.*to have value.*val-c.*but was not in Dict',
self.assertDictHasSubset,
@ -63,7 +66,8 @@ class TestAssertDictHasSubset(ReaderTest):
{'key-c': 'val-c'})
def test_fail_wrong_val(self):
self.assertRaisesRegexp(
six.assertRaisesRegex(
self,
AssertionError,
'Expected .*key-a.* to have value .*val-b.* but was .*val-a.*',
self.assertDictHasSubset,

View file

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
import sys
import warnings
from pelican.tests.support import unittest
class TestSuiteTest(unittest.TestCase):
@unittest.skipIf(sys.version_info[:2] == (3, 3),
"does not throw an exception on python 3.3")
def test_error_on_warning(self):
with self.assertRaises(UserWarning):
warnings.warn('test warning')