Mock subprocess.check_output for download call.
(command_args, encoding=None)
| 594 | """ |
| 595 | |
| 596 | def check_output(command_args, encoding=None): |
| 597 | """Mock subprocess.check_output for download call.""" |
| 598 | assert encoding |
| 599 | assert command_args[2] == 'download' |
| 600 | competition_or_dataset = command_args[-1] |
| 601 | if err_msg: |
| 602 | raise subprocess.CalledProcessError(1, command_args, err_msg) |
| 603 | out_dir = command_args[command_args.index('--path') + 1] |
| 604 | fpath = os.path.join(out_dir, 'output.txt') |
| 605 | with tf.io.gfile.GFile(fpath, 'w') as f: |
| 606 | f.write(competition_or_dataset) |
| 607 | return 'Downloading {} to {}'.format(competition_or_dataset, fpath) |
| 608 | |
| 609 | with mock.patch('subprocess.check_output', check_output): |
| 610 | yield |