@@ -115,125 +115,106 @@ def tearDownClass(self):
115115
116116 def test_one_file_one_match_no_flags (self ):
117117 self .assertMultiLineEqual (
118- grep ("Agamemnon" , [ILIADFILENAME ]),
118+ grep ("Agamemnon" , "" , [ILIADFILENAME ]),
119119 "Of Atreus, Agamemnon, King of men.\n "
120120 )
121121
122122 def test_one_file_one_match_print_line_numbers_flag (self ):
123123 self .assertMultiLineEqual (
124- grep ("Forbidden" , [ PARADISELOSTFILENAME ], "-n" ),
124+ grep ("Forbidden" , "-n" , [ PARADISELOSTFILENAME ] ),
125125 "2:Of that Forbidden Tree, whose mortal tast\n "
126126 )
127127
128128 def test_one_file_one_match_case_insensitive_flag (self ):
129129 self .assertMultiLineEqual (
130- grep ("FORBIDDEN" , [ PARADISELOSTFILENAME ], "-i" ),
130+ grep ("FORBIDDEN" , "-i" , [ PARADISELOSTFILENAME ] ),
131131 "Of that Forbidden Tree, whose mortal tast\n "
132132 )
133133
134134 def test_one_file_one_match_print_file_names_flag (self ):
135135 self .assertMultiLineEqual (
136- grep ("Forbidden" , [PARADISELOSTFILENAME ], "-l" ),
137- PARADISELOSTFILENAME + '\n '
138- )
136+ grep ("Forbidden" , "-l" , [PARADISELOSTFILENAME ]),
137+ PARADISELOSTFILENAME + '\n ' )
139138
140139 def test_one_file_one_match_match_entire_lines_flag (self ):
141140 self .assertMultiLineEqual (
142141 grep ("With loss of Eden, till one greater Man" ,
143- [PARADISELOSTFILENAME ], "-x" ),
144- "With loss of Eden, till one greater Man\n "
145- )
142+ "-x" , [PARADISELOSTFILENAME ]),
143+ "With loss of Eden, till one greater Man\n " )
146144
147145 def test_one_file_one_match_multiple_flags (self ):
148146 self .assertMultiLineEqual (
149- grep (
150- "OF ATREUS, Agamemnon, KIng of MEN." ,
151- [ILIADFILENAME ],
152- "-n -i -x"
153- ),
154- "9:Of Atreus, Agamemnon, King of men.\n "
155- )
147+ grep ("OF ATREUS, Agamemnon, KIng of MEN." ,
148+ "-n -i -x" , [ILIADFILENAME ]),
149+ "9:Of Atreus, Agamemnon, King of men.\n " )
156150
157151 def test_one_file_several_matches_no_flags (self ):
158152 self .assertMultiLineEqual (
159- grep ("may" , [MIDSUMMERNIGHTFILENAME ]),
153+ grep ("may" , "" , [MIDSUMMERNIGHTFILENAME ]),
160154 "Nor how it may concern my modesty,\n "
161155 "But I beseech your grace that I may know\n "
162- "The worst that may befall me in this case,\n "
163- )
156+ "The worst that may befall me in this case,\n " )
164157
165158 def test_one_file_several_matches_print_line_numbers_flag (self ):
166159 self .assertMultiLineEqual (
167- grep ("may" , [ MIDSUMMERNIGHTFILENAME ], "-n" ),
160+ grep ("may" , "-n" , [ MIDSUMMERNIGHTFILENAME ] ),
168161 "3:Nor how it may concern my modesty,\n "
169162 "5:But I beseech your grace that I may know\n "
170- "6:The worst that may befall me in this case,\n "
171- )
163+ "6:The worst that may befall me in this case,\n " )
172164
173165 def test_one_file_several_matches_match_entire_lines_flag (self ):
174166 self .assertMultiLineEqual (
175- grep ("may" , [MIDSUMMERNIGHTFILENAME ], "-x" ),
176- ""
177- )
167+ grep ("may" , "-x" , [MIDSUMMERNIGHTFILENAME ]),
168+ "" )
178169
179170 def test_one_file_several_matches_case_insensitive_flag (self ):
180171 self .assertMultiLineEqual (
181- grep ("ACHILLES" , [ ILIADFILENAME ], "-i" ),
172+ grep ("ACHILLES" , "-i" , [ ILIADFILENAME ] ),
182173 "Achilles sing, O Goddess! Peleus' son;\n "
183- "The noble Chief Achilles from the son\n "
184- )
174+ "The noble Chief Achilles from the son\n " )
185175
186176 def test_one_file_several_matches_inverted_flag (self ):
187177 self .assertMultiLineEqual (
188- grep ("Of" , [ PARADISELOSTFILENAME ], "-v" ),
178+ grep ("Of" , "-v" , [ PARADISELOSTFILENAME ] ),
189179 "Brought Death into the World, and all our woe,\n "
190180 "With loss of Eden, till one greater Man\n "
191181 "Restore us, and regain the blissful Seat,\n "
192182 "Sing Heav'nly Muse, that on the secret top\n "
193- "That Shepherd, who first taught the chosen Seed\n "
194- )
183+ "That Shepherd, who first taught the chosen Seed\n " )
195184
196185 def test_one_file_one_match_file_flag_takes_precedence_over_line (self ):
197186 self .assertMultiLineEqual (
198- grep ("ten" , [ILIADFILENAME ], "-n -l" ),
199- ILIADFILENAME + '\n '
200- )
187+ grep ("ten" , "-n -l" , [ILIADFILENAME ]),
188+ ILIADFILENAME + '\n ' )
201189
202190 def test_one_file_no_matches_various_flags (self ):
203191 self .assertMultiLineEqual (
204- grep ("Gandalf" , [ILIADFILENAME ], "-n -l -x -i" ),
205- ""
206- )
192+ grep ("Gandalf" , "-n -l -x -i" , [ILIADFILENAME ]),
193+ "" )
207194
208195 def test_multiple_files_one_match_no_flags (self ):
209196 self .assertMultiLineEqual (
210- grep ("Agamemnon" , FILENAMES ),
211- "iliad.txt:Of Atreus, Agamemnon, King of men.\n "
212- )
197+ grep ("Agamemnon" , "" , FILENAMES ),
198+ "iliad.txt:Of Atreus, Agamemnon, King of men.\n " )
213199
214200 def test_multiple_files_several_matches_no_flags (self ):
215201 self .assertMultiLineEqual (
216- grep ("may" , FILENAMES ),
202+ grep ("may" , "" , FILENAMES ),
217203 "midsummer-night.txt:Nor how it may concern my modesty,\n "
218204 "midsummer-night.txt:But I beseech your grace that I may know\n "
219- "midsummer-night.txt:The worst that may befall me in this case,\n "
220- )
205+ "midsummer-night.txt:The worst that may befall me in this case,\n " )
221206
222207 def test_multiple_files_several_matches_print_line_numbers_flag (self ):
223208 expected = (
224209 "midsummer-night.txt:5:But I beseech your grace that I may know\n "
225210 "midsummer-night.txt:6:The worst that may befall me in this case,"
226211 "\n paradise-lost.txt:2:Of that Forbidden Tree, whose mortal tast\n "
227- "paradise-lost.txt:6:Sing Heav'nly Muse, that on the secret top\n "
228- )
229- self .assertMultiLineEqual (
230- grep ("that" , FILENAMES , "-n" ),
231- expected
232- )
212+ "paradise-lost.txt:6:Sing Heav'nly Muse, that on the secret top\n " )
213+ self .assertMultiLineEqual (grep ("that" , "-n" , FILENAMES ), expected )
233214
234215 def test_multiple_files_one_match_print_file_names_flag (self ):
235216 self .assertMultiLineEqual (
236- grep ("who" , FILENAMES , "-l" ),
217+ grep ("who" , "-l" , FILENAMES ),
237218 ILIADFILENAME + '\n ' + PARADISELOSTFILENAME + '\n ' )
238219
239220 def test_multiple_files_several_matches_case_insensitive_flag (self ):
@@ -247,44 +228,38 @@ def test_multiple_files_several_matches_case_insensitive_flag(self):
247228 "\n midsummer-night.txt:If I refuse to wed Demetrius.\n "
248229 "paradise-lost.txt:Brought Death into the World, and all our woe,"
249230 "\n paradise-lost.txt:Restore us, and regain the blissful Seat,\n "
250- "paradise-lost.txt:Sing Heav'nly Muse, that on the secret top\n "
251- )
252- self .assertMultiLineEqual (
253- grep ("TO" , FILENAMES , "-i" ),
254- expected
255- )
231+ "paradise-lost.txt:Sing Heav'nly Muse, that on the secret top\n " )
232+ self .assertMultiLineEqual (grep ("TO" , "-i" , FILENAMES ), expected )
256233
257234 def test_multiple_files_several_matches_inverted_flag (self ):
258235 self .assertMultiLineEqual (
259- grep ("a" , FILENAMES , "-v" ),
236+ grep ("a" , "-v" , FILENAMES ),
260237 "iliad.txt:Achilles sing, O Goddess! Peleus' son;\n "
261238 "iliad.txt:The noble Chief Achilles from the son\n "
262239 "midsummer-night.txt:If I refuse to wed Demetrius.\n "
263240 )
264241
265242 def test_multiple_files_one_match_match_entire_lines_flag (self ):
266243 self .assertMultiLineEqual (
267- grep ("But I beseech your grace that I may know" ,
268- FILENAMES , "-x" ),
244+ grep ("But I beseech your grace that I may know" , "-x" , FILENAMES ),
269245 "midsummer-night.txt:But I beseech your grace that I may know\n " )
270246
271247 def test_multiple_files_one_match_multiple_flags (self ):
272248 self .assertMultiLineEqual (
273- grep ("WITH LOSS OF EDEN, TILL ONE GREATER MAN" ,
274- FILENAMES , "-n -i -x" ),
249+ grep ("WITH LOSS OF EDEN, TILL ONE GREATER MAN" , "-n -i -x" ,
250+ FILENAMES ),
275251 "paradise-lost.txt:4:With loss of Eden, till one greater Man\n " )
276252
277253 def test_multiple_files_no_matches_various_flags (self ):
278254 self .assertMultiLineEqual (
279- grep ("Frodo" , FILENAMES , "-n -l -x -i" ),
255+ grep ("Frodo" , "-n -l -x -i" , FILENAMES ),
280256 ""
281257 )
282258
283259 def test_multiple_files_several_matches_file_flag_takes_precedence (self ):
284260 self .assertMultiLineEqual (
285- grep ("who" , FILENAMES , "-n -l" ),
286- ILIADFILENAME + '\n ' + PARADISELOSTFILENAME + '\n '
287- )
261+ grep ("who" , "-n -l" , FILENAMES ),
262+ ILIADFILENAME + '\n ' + PARADISELOSTFILENAME + '\n ' )
288263
289264 def test_multiple_files_several_matches_inverted_match_entire_lines (self ):
290265 expected = (
@@ -314,7 +289,7 @@ def test_multiple_files_several_matches_inverted_match_entire_lines(self):
314289 "\n "
315290 )
316291 self .assertMultiLineEqual (
317- grep ("Illustrious into Ades premature," , FILENAMES , "-x -v" ),
292+ grep ("Illustrious into Ades premature," , "-x -v" , FILENAMES ),
318293 expected
319294 )
320295
0 commit comments