def test_insecure_platform_is_supresed(self): _reset_platform_warning() self.method.side_effect = self._warn_and_respond(InsecurePlatformWarning) with warnings.catch_warnings(record=True) as warns: response = request(self.method, sentinel.url) eq_(warns, []) eq_(response, self.response)
def test_not_all_warnings_are__supresed(self): _reset_platform_warning() self.method.side_effect = self._warn_and_respond(Warning, 'warning_message') with warnings.catch_warnings(record=True) as warns: response = request(self.method, sentinel.url) eq_(len(warns), 1) self.assertIn('warning_message', str(warns[0])) eq_(response, self.response)
def test_insecure_platform_message_is_printed(self): _reset_platform_warning() self.method.side_effect = self._warn_and_respond(InsecurePlatformWarning) buff = six.StringIO() sys.stdout = buff try: request(self.method, sentinel.url) finally: sys.stdout = sys.__stdout__ self.assertIn('Got an InsecurePlatformWarning. Upgrade python to 2.7.9 or better to remove.', buff.getvalue())