def test_rip_error(request, tmpdir):
"""Test failed rips error handling.
:param request: pytest fixture.
:param py.path.local tmpdir: pytest fixture.
"""
# Duplicate ISO.
iso = tmpdir.join('truncated.iso')
py.path.local(__file__).dirpath().join('sample.iso').copy(iso)
# Load the ISO.
pytest.cdload(iso)
# Execute.
output = tmpdir.ensure_dir('output')
command = ['docker', 'run', '--device=/dev/cdrom', '-v', '{}:/output'.format(output), '-e', 'DEBUG=true',
'robpol86/makemkv']
master, slave = pty.openpty()
request.addfinalizer(lambda: [os.close(master), os.close(slave)])
proc = subprocess.Popen(command, bufsize=1, cwd=HERE, stderr=subprocess.STDOUT, stdin=slave, stdout=subprocess.PIPE)
# Read output.
caught = False
while proc.poll() is None or proc.stdout.peek(1):
for line in proc.stdout:
# Watch for specific line, then truncate ISO.
if b'Analyzing seamless segments' in line:
iso.open('w').close()
elif b'ERROR: One or more titles failed.' in line:
caught = True
print(line) # Write to stdout, pytest will print if test fails.
# Verify.
assert proc.poll() > 0
assert caught is True
pytest.verify_failed_file(output)
评论列表
文章目录