Commits

Andriy Kornatskyy committed 69cfba1

Added wranings check test case.

  • Participants
  • Parent commits 7b596eb

Comments (0)

Files changed (1)

src/wheezy/web/middleware/tests/test_bootstrap.py

         from wheezy.web.middleware import bootstrap
         self.patcher = patch.object(bootstrap, 'bootstrap_http_defaults')
         self.patcher.start()
+        try:
+            from warnings import catch_warnings
+            self.ctx = catch_warnings(record=True)
+            self.w = self.ctx.__enter__()
+        except ImportError:
+            self.ctx = None
 
     def tearDown(self):
         self.patcher.stop()
+        if self.ctx:
+            self.ctx.__exit__(None, None, None)
+
+    def assert_warning(self, msg):
+        if self.ctx:
+            assert len(self.w) == 1
+            self.assertEquals(msg, str(self.w[-1].message))
 
     def test_default_options(self):
         """ Ensure required keys exist.
         })(options)
 
         assert tuple(options.keys())
+
+    def test_warnings(self):
+        """ Ensure warnings are issued.
+        """
+        from wheezy.web.middleware.bootstrap import bootstrap_defaults
+        options = {
+            'ticket': None
+        }
+
+        assert None == bootstrap_defaults({})(options)
+        self.assert_warning('Bootstrap: render_template is not defined')