(self)
| 173 | |
| 174 | class TestCheckEnviron(unittest.TestCase): |
| 175 | def test_no_query_string(self): |
| 176 | environ = { |
| 177 | 'REQUEST_METHOD': 'GET', |
| 178 | 'SERVER_NAME': 'localhost', |
| 179 | 'SERVER_PORT': '80', |
| 180 | 'wsgi.version': (1, 0, 1), |
| 181 | 'wsgi.input': StringIO('test'), |
| 182 | 'wsgi.errors': StringIO(), |
| 183 | 'wsgi.multithread': None, |
| 184 | 'wsgi.multiprocess': None, |
| 185 | 'wsgi.run_once': None, |
| 186 | 'wsgi.url_scheme': 'http', |
| 187 | 'PATH_INFO': '/', |
| 188 | } |
| 189 | with warnings.catch_warnings(record=True) as w: |
| 190 | warnings.simplefilter("always") |
| 191 | check_environ(environ) |
| 192 | self.assertEqual(len(w), 1, "We should have only one warning") |
| 193 | self.assertTrue( |
| 194 | "QUERY_STRING" in str(w[-1].message), |
| 195 | "The warning message should say something about QUERY_STRING") |
| 196 | |
| 197 | def test_no_valid_request(self): |
| 198 | environ = { |
nothing calls this directly
no test coverage detected