[Tests][Fixed] RAR fail test

- Now uses _run_command, so we need to patch it
This commit is contained in:
Salvador E. Tropea 2024-01-08 13:01:53 -03:00
parent e64b3864b4
commit 19b29f6f6d
1 changed files with 9 additions and 0 deletions

View File

@ -28,6 +28,7 @@ cov = coverage.Coverage()
mocked_check_output_FNF = True
mocked_check_output_retOK = ''
mocked_call_enabled = False
subprocess_run = None
# Important note:
@ -47,6 +48,13 @@ def mocked_check_output(cmd, stderr=None, text=False):
raise e
def mocked_run(command, change_to):
logging.error('mocked_run')
e = subprocess.CalledProcessError(10, 'rar')
e.output = b'THE_ERROR'
raise e
def mocked_call(cmd, exit_with=None):
if mocked_call_enabled:
logging.debug('Forcing fail on '+str(cmd))
@ -118,6 +126,7 @@ def test_rar_fail(test_dir, caplog, monkeypatch):
# We will patch subprocess.check_output to make rar fail
with monkeypatch.context() as m:
patch_functions(m)
m.setattr('kibot.kiplot._run_command', mocked_run)
pytest_wrapped_e = run_compress(ctx)
pytest_wrapped_e2 = run_compress(ctx, test_import_fail=True)
# Check we exited because rar isn't installed