Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3)

Side by Side Diff: Lib/test/test_cgi.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 7 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_capi.py ('k') | Lib/test/test_cmd_line.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from test.support import run_unittest, check_warnings 1 from test.support import run_unittest, check_warnings
2 import cgi 2 import cgi
3 import os 3 import os
4 import sys 4 import sys
5 import tempfile 5 import tempfile
6 import unittest 6 import unittest
7 import warnings 7 import warnings
8 from io import StringIO, BytesIO 8 from io import StringIO, BytesIO
9 9
10 class HackedSysModule: 10 class HackedSysModule:
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 f = TestReadlineFile(tempfile.TemporaryFile("wb+")) 195 f = TestReadlineFile(tempfile.TemporaryFile("wb+"))
196 self.addCleanup(f.close) 196 self.addCleanup(f.close)
197 f.write(b'x' * 256 * 1024) 197 f.write(b'x' * 256 * 1024)
198 f.seek(0) 198 f.seek(0)
199 env = {'REQUEST_METHOD':'PUT'} 199 env = {'REQUEST_METHOD':'PUT'}
200 fs = cgi.FieldStorage(fp=f, environ=env) 200 fs = cgi.FieldStorage(fp=f, environ=env)
201 self.addCleanup(fs.file.close) 201 self.addCleanup(fs.file.close)
202 # if we're not chunking properly, readline is only called twice 202 # if we're not chunking properly, readline is only called twice
203 # (by read_binary); if we are chunking properly, it will be called 5 tim es 203 # (by read_binary); if we are chunking properly, it will be called 5 tim es
204 # as long as the chunksize is 1 << 16. 204 # as long as the chunksize is 1 << 16.
205 self.assertTrue(f.numcalls > 2) 205 self.assertGreater(f.numcalls, 2)
206 f.close() 206 f.close()
207 207
208 def test_fieldstorage_multipart(self): 208 def test_fieldstorage_multipart(self):
209 #Test basic FieldStorage multipart parsing 209 #Test basic FieldStorage multipart parsing
210 env = { 210 env = {
211 'REQUEST_METHOD': 'POST', 211 'REQUEST_METHOD': 'POST',
212 'CONTENT_TYPE': 'multipart/form-data; boundary={}'.format(BOUNDARY), 212 'CONTENT_TYPE': 'multipart/form-data; boundary={}'.format(BOUNDARY),
213 'CONTENT_LENGTH': '558'} 213 'CONTENT_LENGTH': '558'}
214 fp = BytesIO(POSTDATA.encode('latin-1')) 214 fp = BytesIO(POSTDATA.encode('latin-1'))
215 fs = cgi.FieldStorage(fp, environ=env, encoding="latin-1") 215 fs = cgi.FieldStorage(fp, environ=env, encoding="latin-1")
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 \xe7\xf1\x80 386 \xe7\xf1\x80
387 -----------------------------721837373350705526688164684 387 -----------------------------721837373350705526688164684
388 """ 388 """
389 389
390 390
391 def test_main(): 391 def test_main():
392 run_unittest(CgiTests) 392 run_unittest(CgiTests)
393 393
394 if __name__ == '__main__': 394 if __name__ == '__main__':
395 test_main() 395 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_capi.py ('k') | Lib/test/test_cmd_line.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+