Code Duplication    Length = 14-15 lines in 2 locations

tests/test_run.py 1 location

@@ 228-241 (lines=14) @@
225
    assert not observer.failed_event.called
226
227
228
@pytest.mark.parametrize("capture_mode", ["no", "sys", "fd"])
229
def test_stdout_capturing(run, capsys, capture_mode):
230
    if sys.platform.startswith('win') and capture_mode == "fd":
231
        return  # skip fd mode under windows
232
233
    def print_mock_progress():
234
        for i in range(10):
235
            print(i, end="")
236
        sys.stdout.flush()
237
238
    run.main_function.side_effect = print_mock_progress
239
    run.capture_mode = capture_mode
240
    with capsys.disabled():
241
        run()
242
    if capture_mode != "no":
243
        assert run.captured_out == '0123456789'
244

tests/test_experiment.py 1 location

@@ 179-193 (lines=15) @@
176
    assert ex.run(named_configs=['ncfg']).result == 10
177
178
179
def test_captured_out_filter(ex, capsys):
180
    @ex.main
181
    def run_print_mock_progress():
182
        sys.stdout.write('progress 0')
183
        sys.stdout.flush()
184
        for i in range(10):
185
            sys.stdout.write('\b')
186
            sys.stdout.write("{}".format(i))
187
            sys.stdout.flush()
188
189
    ex.captured_out_filter = apply_backspaces_and_linefeeds
190
    # disable logging and set capture mode to python
191
    options = {'--loglevel': 'CRITICAL', '--capture': 'sys'}
192
    with capsys.disabled():
193
        assert ex.run(options=options).captured_out == 'progress 9'
194
195
196
def test_adding_option_hooks(ex):