Example #1
0
 def test_handles_native_strings_in_variables(self):
     path = '/umläut'
     environ = {
         'REQUEST_METHOD': 'GET',
         'SERVER_NAME': 'localhost',
         'SERVER_PORT': '80',
         'wsgi.version': (1, 0, 1),
         'wsgi.input': StringIO('test'),
         'wsgi.errors': StringIO(),
         'wsgi.multithread': None,
         'wsgi.multiprocess': None,
         'wsgi.run_once': None,
         'wsgi.url_scheme': 'http',
         'PATH_INFO': path,
         'QUERY_STRING': '',
     }
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter("always")
         check_environ(environ)
         self.assertEqual(0, len(w), "We should have no warning")
Example #2
0
 def test_no_query_string(self):
     environ = {
         'REQUEST_METHOD': str('GET'),
         'SERVER_NAME': str('localhost'),
         'SERVER_PORT': str('80'),
         'wsgi.version': (1, 0, 1),
         'wsgi.input': StringIO('test'),
         'wsgi.errors': StringIO(),
         'wsgi.multithread': None,
         'wsgi.multiprocess': None,
         'wsgi.run_once': None,
         'wsgi.url_scheme': 'http',
         'PATH_INFO': str('/'),
     }
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter("always")
         check_environ(environ)
         self.assertEqual(len(w), 1, "We should have only one warning")
         self.assertTrue("QUERY_STRING" in str(w[-1].message),
             "The warning message should say something about QUERY_STRING")
Example #3
0
 def test_no_query_string(self):
     environ = {
         'REQUEST_METHOD': 'GET',
         'SERVER_NAME': 'localhost',
         'SERVER_PORT': '80',
         'wsgi.version': (1, 0, 1),
         'wsgi.input': StringIO('test'),
         'wsgi.errors': StringIO(),
         'wsgi.multithread': None,
         'wsgi.multiprocess': None,
         'wsgi.run_once': None,
         'wsgi.url_scheme': 'http',
         'PATH_INFO': '/',
     }
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter("always")
         check_environ(environ)
         self.assertEqual(len(w), 1, "We should have only one warning")
         self.assertTrue(
             "QUERY_STRING" in str(w[-1].message),
             "The warning message should say something about QUERY_STRING")
Example #4
0
 def test_handles_native_strings_in_variables(self):
     # "native string" means unicode in py3, but bytes in py2
     path = '/umläut'
     if not PY3:
         path = path.encode('utf-8')
     environ = {
         'REQUEST_METHOD': str('GET'),
         'SERVER_NAME': str('localhost'),
         'SERVER_PORT': str('80'),
         'wsgi.version': (1, 0, 1),
         'wsgi.input': StringIO('test'),
         'wsgi.errors': StringIO(),
         'wsgi.multithread': None,
         'wsgi.multiprocess': None,
         'wsgi.run_once': None,
         'wsgi.url_scheme': 'http',
         'PATH_INFO': path,
         'QUERY_STRING': str(''),
     }
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter("always")
         check_environ(environ)
         self.assertEqual(0, len(w), "We should have no warning")