Skip to content

Commit c79cdbf

Browse files
committed
Fix typo
1 parent b936edf commit c79cdbf

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

quark/utils/tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def update_rizin(source_path, target_commit) -> Boolean:
256256
for line in _execute_command(["rm", "-rf", "build"], cwd=source_path):
257257
print_info(line)
258258

259-
# Clean out old subproject
259+
# Clean out old subprojects
260260
for line in _execute_command(
261261
["git", "clean", "-dxff", "subprojects/"], cwd=source_path
262262
):
@@ -296,7 +296,7 @@ def update_rizin(source_path, target_commit) -> Boolean:
296296

297297
except CalledProcessError as error:
298298
pass
299-
except OSError:
299+
except OSError as error:
300300
pass
301301

302302
print_error("An error occurred when updating Rizin.\n")
@@ -323,7 +323,7 @@ def find_rizin_instance(
323323
324324
:param rizin_source_path: a path to the source code of Rizin. Defaults to
325325
RIZIN_DIR
326-
:param target_commit: a commmit specifying the Rizin version to compile.
326+
:param target_commit: a commit specifying the Rizin version to compile.
327327
Defaults to RIZIN_COMMIT
328328
:param disable_rizin_installation: a flag to disable the automatic
329329
installation of Rizin. Defaults to False

tests/utils/test_tools.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
22
import re
33
import shutil
4-
from subprocess import PIPE, CalledProcessError, run # nosec
4+
from subprocess import PIPE, CalledProcessError, Popen, run
5+
from sys import stderr # nosec
56
from unittest.mock import patch
67

78
import pytest
@@ -26,7 +27,7 @@ def rizin_in_system_path():
2627

2728

2829
@pytest.fixture(scope="module")
29-
def rizin_version():
30+
def version_of_rizin_installed_on_system():
3031
rizin_in_system_path = shutil.which("rizin")
3132
try:
3233
process = run( # nosec
@@ -164,9 +165,9 @@ def test_descriptor_to_androguard_format_with_combination():
164165

165166

166167
def test_get_rizin_version_with_valid_path(
167-
rizin_in_system_path, rizin_version
168+
rizin_in_system_path, version_of_rizin_installed_on_system
168169
):
169-
expected_version = rizin_version
170+
expected_version = version_of_rizin_installed_on_system
170171

171172
found_version = _get_rizin_version(rizin_in_system_path)
172173

@@ -180,15 +181,15 @@ def test_get_rizin_version_with_invalid_path(tmp_path):
180181
def test_download_rizin_successfully(tmp_path):
181182
target_path = tmp_path / "rizin"
182183

183-
download_rizin(target_path)
184-
185-
assert os.access(target_path, os.F_OK | os.X_OK)
184+
with patch("quark.utils.tools._execute_command") as mock:
185+
download_rizin(target_path)
186+
mock.assert_called_once()
186187

187188

188189
def test_fail_to_download_rizin_due_to_unavailable_network(tmp_path):
189190
target_path = tmp_path / "rizin"
190191

191-
with patch("subprocess.Popen") as mock:
192+
with patch("subprocess.Popen.__new__") as mock:
192193
mock.side_effect = CalledProcessError(
193194
"1",
194195
"mock command",
@@ -202,7 +203,7 @@ def test_fail_to_download_rizin_due_to_unavailable_network(tmp_path):
202203
def test_fail_to_download_rizin_due_to_unknown_errors(tmp_path):
203204
target_path = tmp_path / "rizin"
204205

205-
with patch("subprocess.Popen") as mock:
206+
with patch("subprocess.Popen.__new__") as mock:
206207
mock.side_effect = CalledProcessError("1", "mock command", stderr=b"")
207208

208209
assert not download_rizin(target_path)
@@ -254,13 +255,13 @@ def test_find_rizin_instance_installed_in_quark_directory():
254255
target_commit = "Unused"
255256

256257
with patch("shutil.which") as mocked_which:
257-
# Pretent there is no Rizin instance installed in the system.
258+
# Pretend there is no Rizin instance installed in the system.
258259
mocked_which.return_value = None
259260

260261
with patch(
261262
"quark.utils.tools._get_rizin_version"
262263
) as mocked_get_version:
263-
# Pretent the Rizin instance installed in the Quark directory is
264+
# Pretend the Rizin instance installed in the Quark directory is
264265
# compatible.
265266
mocked_get_version.return_value = config.COMPATIBLE_RAZIN_VERSIONS[
266267
0
@@ -286,20 +287,20 @@ def test_find_outdated_rizin_instance_installed_in_quark_directory(
286287
target_commit = "Unused"
287288

288289
with patch("shutil.which") as mocked_which:
289-
# Pretent there is no Rizin instance installed in the system.
290+
# Pretend there is no Rizin instance installed in the system.
290291
mocked_which.return_value = None
291292

292293
with patch(
293294
"quark.utils.tools._get_rizin_version"
294295
) as mocked_get_version:
295-
# Pretent the Rizin instance installed in the Quark directory is
296+
# Pretend the Rizin instance installed in the Quark directory is
296297
# not compatible.
297298
mocked_get_version.return_value = "0.0.0"
298299

299300
with patch(
300301
"quark.utils.tools.update_rizin"
301302
) as mocked_update_rizin:
302-
# Pretent the upgrade is finished successfully.
303+
# Pretend the upgrade is finished successfully.
303304
mocked_update_rizin.return_value = True
304305

305306
# Must use the instance in the Quark directory.
@@ -342,13 +343,13 @@ def test_find_broken_rizin_instance_installed_in_quark_directory(
342343
target_commit = "Unused"
343344

344345
with patch("shutil.which") as mocked_which:
345-
# Pretent there is no Rizin instance installed in the system.
346+
# Pretend there is no Rizin instance installed in the system.
346347
mocked_which.return_value = "rizin_installed_in_system"
347348

348349
with patch(
349350
"quark.utils.tools._get_rizin_version"
350351
) as mocked_get_version:
351-
# Pretent -
352+
# Pretend -
352353
# 1. the Rizin instance in the system path is not compatible
353354
# 2. the Rizin instance in the Quark directory is broken.
354355
mocked_get_version.side_effect = (
@@ -360,15 +361,15 @@ def test_find_broken_rizin_instance_installed_in_quark_directory(
360361
with patch(
361362
"quark.utils.tools.download_rizin"
362363
) as mocked_download_rizin:
363-
# Pretent we can download the source code successfully.
364+
# Pretend we can download the source code successfully.
364365
mocked_download_rizin.side_effect = (
365366
_side_effort_for_downloading_rizin
366367
)
367368

368369
with patch(
369370
"quark.utils.tools.update_rizin"
370371
) as mocked_update_rizin:
371-
# Pretent we can finish the upgrade successfully.
372+
# Pretend we can finish the upgrade successfully.
372373
mocked_update_rizin.return_value = True
373374

374375
result = find_rizin_instance(
@@ -406,13 +407,13 @@ def test_find_rizin_instance_failed_to_download_the_source():
406407
target_commit = "Unused"
407408

408409
with patch("shutil.which") as mocked_which:
409-
# Pretent there is no Rizin instance installed in the system.
410+
# Pretend there is no Rizin instance installed in the system.
410411
mocked_which.return_value = None
411412

412413
with patch(
413414
"quark.utils.tools._get_rizin_version"
414415
) as mocked_get_version:
415-
# Pretent the Rizin instance installed in the Quark directory is
416+
# Pretend the Rizin instance installed in the Quark directory is
416417
# broken.
417418
mocked_get_version.return_value = None
418419

@@ -442,20 +443,20 @@ def test_find_rizin_instance_failed_to_compile_or_update_the_source():
442443
target_commit = "Unused"
443444

444445
with patch("shutil.which") as mocked_which:
445-
# Pretent there is no Rizin instance installed in the system.
446+
# Pretend there is no Rizin instance installed in the system.
446447
mocked_which.return_value = None
447448

448449
with patch(
449450
"quark.utils.tools._get_rizin_version"
450451
) as mocked_get_version:
451-
# Pretent the Rizin instance installed in the Quark directory is
452+
# Pretend the Rizin instance installed in the Quark directory is
452453
# not compatible.
453454
mocked_get_version.return_value = "0.0.0"
454455

455456
with patch(
456457
"quark.utils.tools.update_rizin"
457458
) as mocked_update_rizin:
458-
# Pretent the upgrade is finished successfully.
459+
# Pretend the upgrade is finished successfully.
459460
mocked_update_rizin.return_value = False
460461

461462
# Must use the instance in the Quark directory.

0 commit comments

Comments
 (0)