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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 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_grammar.py ('k') | Lib/test/test_hmac.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 """Test script for the gzip module. 1 """Test script for the gzip module.
2 """ 2 """
3 3
4 import unittest 4 import unittest
5 from test import support 5 from test import support
6 import os 6 import os
7 import io 7 import io
8 import struct 8 import struct
9 gzip = support.import_module('gzip') 9 gzip = support.import_module('gzip')
10 10
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 def test_readline(self): 152 def test_readline(self):
153 self.test_write() 153 self.test_write()
154 # Try .readline() with varying line lengths 154 # Try .readline() with varying line lengths
155 155
156 with gzip.GzipFile(self.filename, 'rb') as f: 156 with gzip.GzipFile(self.filename, 'rb') as f:
157 line_length = 0 157 line_length = 0
158 while 1: 158 while 1:
159 L = f.readline(line_length) 159 L = f.readline(line_length)
160 if not L and line_length != 0: break 160 if not L and line_length != 0: break
161 self.assertTrue(len(L) <= line_length) 161 self.assertLessEqual(len(L), line_length)
162 line_length = (line_length + 1) % 50 162 line_length = (line_length + 1) % 50
163 163
164 def test_readlines(self): 164 def test_readlines(self):
165 self.test_write() 165 self.test_write()
166 # Try .readlines() 166 # Try .readlines()
167 167
168 with gzip.GzipFile(self.filename, 'rb') as f: 168 with gzip.GzipFile(self.filename, 'rb') as f:
169 L = f.readlines() 169 L = f.readlines()
170 170
171 with gzip.GzipFile(self.filename, 'rb') as f: 171 with gzip.GzipFile(self.filename, 'rb') as f:
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 with gzip.open(self.filename, "wt", newline="\n") as f: 545 with gzip.open(self.filename, "wt", newline="\n") as f:
546 f.write(uncompressed) 546 f.write(uncompressed)
547 with gzip.open(self.filename, "rt", newline="\r") as f: 547 with gzip.open(self.filename, "rt", newline="\r") as f:
548 self.assertEqual(f.readlines(), [uncompressed]) 548 self.assertEqual(f.readlines(), [uncompressed])
549 549
550 def test_main(verbose=None): 550 def test_main(verbose=None):
551 support.run_unittest(TestGzip, TestOpen) 551 support.run_unittest(TestGzip, TestOpen)
552 552
553 if __name__ == "__main__": 553 if __name__ == "__main__":
554 test_main(verbose=True) 554 test_main(verbose=True)
OLDNEW
« no previous file with comments | « Lib/test/test_grammar.py ('k') | Lib/test/test_hmac.py » ('j') | no next file with comments »

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