summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-08-30 14:44:04 -0400
committerChris McDonough <chrism@plope.com>2013-08-30 14:44:04 -0400
commit91d5134ec4c6d8032630f6192714b34019a21d2c (patch)
tree2354f01a1926c5770bf9e44b7bb7d7ddaeab13f0
parente01b1caa07080eea690ba73d1cdfc7bc9ac3dccb (diff)
downloadpyramid-91d5134ec4c6d8032630f6192714b34019a21d2c.tar.gz
pyramid-91d5134ec4c6d8032630f6192714b34019a21d2c.tar.bz2
pyramid-91d5134ec4c6d8032630f6192714b34019a21d2c.zip
squash console output during test runs
-rw-r--r--pyramid/mako_templating.py4
-rw-r--r--pyramid/tests/test_mako_templating.py17
2 files changed, 19 insertions, 2 deletions
diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py
index c07ee227f..01456c3d4 100644
--- a/pyramid/mako_templating.py
+++ b/pyramid/mako_templating.py
@@ -204,6 +204,8 @@ class MakoLookupTemplateRenderer(object):
package:path/to/template#defname.mako, a function named ``defname``
inside the template will then be rendered.
"""
+ warnings = warnings # for testing
+
def __init__(self, path, defname, lookup):
self.path = path
self.defname = defname
@@ -218,7 +220,7 @@ class MakoLookupTemplateRenderer(object):
system['_context'] = context
# tuple returned to be deprecated
if isinstance(value, tuple):
- warnings.warn(
+ self.warnings.warn(
'Using a tuple in the form (\'defname\', {}) to render a '
'Mako partial will be deprecated in the future. Use a '
'Mako template renderer as documented in the "Using A '
diff --git a/pyramid/tests/test_mako_templating.py b/pyramid/tests/test_mako_templating.py
index a57ac0aaa..69485ca19 100644
--- a/pyramid/tests/test_mako_templating.py
+++ b/pyramid/tests/test_mako_templating.py
@@ -396,10 +396,13 @@ class MakoLookupTemplateRendererTests(Base, maybe_unittest()):
def test_call_with_tuple_value(self):
lookup = DummyLookup()
instance = self._makeOne('path', None, lookup)
+ warnings = DummyWarnings()
+ instance.warnings = warnings
result = instance(('fub', {}), {'context':1})
self.assertEqual(lookup.deffed, 'fub')
self.assertEqual(result, text_('result'))
self.assertEqual(lookup.values, {'_context':1})
+ self.assertEqual(len(warnings.msgs), 1)
def test_call_with_defname(self):
lookup = DummyLookup()
@@ -411,26 +414,32 @@ class MakoLookupTemplateRendererTests(Base, maybe_unittest()):
def test_call_with_defname_with_tuple_value(self):
lookup = DummyLookup()
instance = self._makeOne('path', 'defname', lookup)
+ warnings = DummyWarnings()
+ instance.warnings = warnings
result = instance(('defname', {}), {'context':1})
self.assertEqual(lookup.deffed, 'defname')
self.assertEqual(result, text_('result'))
self.assertEqual(lookup.values, {'_context':1})
+ self.assertEqual(len(warnings.msgs), 1)
def test_call_with_defname_with_tuple_value_twice(self):
lookup = DummyLookup()
instance1 = self._makeOne('path', 'defname', lookup)
+ warnings = DummyWarnings()
+ instance1.warnings = warnings
result1 = instance1(('defname1', {}), {'context':1})
self.assertEqual(lookup.deffed, 'defname1')
self.assertEqual(result1, text_('result'))
self.assertEqual(lookup.values, {'_context':1})
instance2 = self._makeOne('path', 'defname', lookup)
+ warnings = DummyWarnings()
+ instance2.warnings = warnings
result2 = instance2(('defname2', {}), {'context':2})
self.assertNotEqual(lookup.deffed, 'defname1')
self.assertEqual(lookup.deffed, 'defname2')
self.assertEqual(result2, text_('result'))
self.assertEqual(lookup.values, {'_context':2})
-
def test_call_with_nondict_value(self):
lookup = DummyLookup()
instance = self._makeOne('path', None, lookup)
@@ -638,3 +647,9 @@ class DummyRendererInfo(object):
def __init__(self, kw):
self.__dict__.update(kw)
+
+class DummyWarnings(object):
+ def __init__(self):
+ self.msgs = []
+ def warn(self, msg, typ, level):
+ self.msgs.append(msg)