@@ -121,7 +121,8 @@ def test_main_pull(mocker, args: list, output: str):
121121 stdin_mock = """
122122 br:br08005
123123 br:br08902
124-
124+ br:br08431
125+
125126 br:br03220
126127 br:br03222
127128 """
@@ -130,18 +131,22 @@ def test_main_pull(mocker, args: list, output: str):
130131
131132 successful_entry_ids = [
132133 'br:br08005' ,
133- 'br:br08902'
134+ 'br:br08902' ,
135+ 'br:br08431'
134136 ]
135137
138+ # The expected output file names have underscores instead of colons in case testing on Windows.
139+ expected_output_files : list = [entry_id .replace (':' , '_' ) for entry_id in successful_entry_ids ]
140+
136141 expected_pull_results = {
137142 'successful-entry-ids' : successful_entry_ids ,
138143 'failed-entry-ids' : ['br:br03220' , 'br:br03222' ],
139144 'timed-out-entry-ids' : [],
140- 'num-successful' : 2 ,
145+ 'num-successful' : 3 ,
141146 'num-failed' : 2 ,
142147 'num-timed-out' : 0 ,
143- 'num-total' : 4 ,
144- 'percent-success' : 50 .0 ,
148+ 'num-total' : 5 ,
149+ 'percent-success' : 60 .0 ,
145150 'pull-minutes' : 1.0
146151 }
147152
@@ -153,22 +158,23 @@ def test_main_pull(mocker, args: list, output: str):
153158
154159 assert time_mock .call_count == 2
155160
156- if output .endswith ('.zip' ):
157- with zf .ZipFile (output , 'r' ) as actual_zip :
158- with zf .ZipFile (f'dev/test_data/{ output } ' , 'r' ) as expected_zip :
159- for successful_entry_id in successful_entry_ids :
160- actual_entry : str = actual_zip .read (successful_entry_id + '.txt' ).decode ()
161- expected_entry : str = expected_zip .read (successful_entry_id + '.txt' ).decode ()
161+ # If running on Windows, change the actual files names to have underscores instead of colons.
162+ if os .name == 'nt' : # pragma: no cover
163+ expected_output_files : list = expected_output_files [:- 1 ] # The last brite gives different output on Windows
164+ successful_entry_ids : list = expected_output_files # pragma: no cover
162165
163- assert actual_entry == expected_entry
164- else :
165- for successful_entry_id in successful_entry_ids :
166+ for successful_entry_id , expected_output_file in zip (successful_entry_ids , expected_output_files ):
167+ if output .endswith ('.zip' ):
168+ with zf .ZipFile (output , 'r' ) as actual_zip :
169+ actual_entry : str = actual_zip .read (successful_entry_id + '.txt' ).decode ()
170+ else :
166171 with open (f'{ output } /{ successful_entry_id } .txt' ) as actual_file :
167- with open (f'dev/test_data/{ output } /{ successful_entry_id } .txt' ) as expected_file :
168- actual_entry : str = actual_file .read ()
169- expected_entry : str = expected_file .read ()
172+ actual_entry : str = actual_file .read ()
173+
174+ with open (f'dev/test_data/brite-entries/{ expected_output_file } .txt' ) as expected_file :
175+ expected_entry : str = expected_file .read ()
170176
171- assert actual_entry == expected_entry
177+ assert actual_entry == expected_entry
172178
173179 with open ('pull-results.json' , 'r' ) as file :
174180 actual_pull_results : dict = j .load (file )
0 commit comments