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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 6 years 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_heapq.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 #! /usr/bin/env python3 1 #! /usr/bin/env python3
2 """Test script for the gzip module. 2 """Test script for the gzip module.
3 """ 3 """
4 4
5 import unittest 5 import unittest
6 from test import support 6 from test import support
7 import os 7 import os
8 import io 8 import io
9 import struct 9 import struct
10 gzip = support.import_module('gzip') 10 gzip = support.import_module('gzip')
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 def test_readline(self): 145 def test_readline(self):
146 self.test_write() 146 self.test_write()
147 # Try .readline() with varying line lengths 147 # Try .readline() with varying line lengths
148 148
149 with gzip.GzipFile(self.filename, 'rb') as f: 149 with gzip.GzipFile(self.filename, 'rb') as f:
150 line_length = 0 150 line_length = 0
151 while 1: 151 while 1:
152 L = f.readline(line_length) 152 L = f.readline(line_length)
153 if not L and line_length != 0: break 153 if not L and line_length != 0: break
154 self.assertTrue(len(L) <= line_length) 154 self.assertLessEqual(len(L), line_length)
155 line_length = (line_length + 1) % 50 155 line_length = (line_length + 1) % 50
156 156
157 def test_readlines(self): 157 def test_readlines(self):
158 self.test_write() 158 self.test_write()
159 # Try .readlines() 159 # Try .readlines()
160 160
161 with gzip.GzipFile(self.filename, 'rb') as f: 161 with gzip.GzipFile(self.filename, 'rb') as f:
162 L = f.readlines() 162 L = f.readlines()
163 163
164 with gzip.GzipFile(self.filename, 'rb') as f: 164 with gzip.GzipFile(self.filename, 'rb') as f:
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 with gzip.open(self.filename, "wt", newline="\n") as f: 488 with gzip.open(self.filename, "wt", newline="\n") as f:
489 f.write(uncompressed) 489 f.write(uncompressed)
490 with gzip.open(self.filename, "rt", newline="\r") as f: 490 with gzip.open(self.filename, "rt", newline="\r") as f:
491 self.assertEqual(f.readlines(), [uncompressed]) 491 self.assertEqual(f.readlines(), [uncompressed])
492 492
493 def test_main(verbose=None): 493 def test_main(verbose=None):
494 support.run_unittest(TestGzip, TestOpen) 494 support.run_unittest(TestGzip, TestOpen)
495 495
496 if __name__ == "__main__": 496 if __name__ == "__main__":
497 test_main(verbose=True) 497 test_main(verbose=True)
OLDNEW
« no previous file with comments | « Lib/test/test_grammar.py ('k') | Lib/test/test_heapq.py » ('j') | no next file with comments »

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