Silence DeprecationWarning for cgi.escape() usage in test_cgi.

This commit is contained in:
Brett Cannon 2012-04-25 20:49:19 -04:00
parent f96bb2f9af
commit 8f79dd5d7c
1 changed files with 8 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import os
import sys import sys
import tempfile import tempfile
import unittest import unittest
import warnings
from io import StringIO, BytesIO from io import StringIO, BytesIO
class HackedSysModule: class HackedSysModule:
@ -119,6 +120,10 @@ def gen_result(data, environ):
class CgiTests(unittest.TestCase): class CgiTests(unittest.TestCase):
def test_escape(self): def test_escape(self):
# cgi.escape() is deprecated.
with warnings.catch_warnings():
warnings.filterwarnings('ignore', 'cgi\.escape',
DeprecationWarning)
self.assertEqual("test & string", cgi.escape("test & string")) self.assertEqual("test & string", cgi.escape("test & string"))
self.assertEqual("&lt;test string&gt;", cgi.escape("<test string>")) self.assertEqual("&lt;test string&gt;", cgi.escape("<test string>"))
self.assertEqual("&quot;test string&quot;", cgi.escape('"test string"', True)) self.assertEqual("&quot;test string&quot;", cgi.escape('"test string"', True))