Skip to content

Commit

Permalink
[Tests][Fixed] RAR fail test
Browse files Browse the repository at this point in the history
- Now uses _run_command, so we need to patch it
  • Loading branch information
set-soft committed Jan 8, 2024
1 parent e64b386 commit 19b29f6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_plot/test_misc_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
mocked_check_output_FNF = True
mocked_check_output_retOK = ''
mocked_call_enabled = False
subprocess_run = None


# Important note:
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 19b29f6

Please sign in to comment.