6
6
7
7
import pytest
8
8
from quark import config
9
- from quark .utils .tools import (contains , descriptor_to_androguard_format ,
10
- download_rizin , find_rizin_instance ,
11
- get_rizin_version , remove_dup_list ,
12
- update_rizin )
9
+ from quark .utils .tools import (
10
+ contains ,
11
+ descriptor_to_androguard_format ,
12
+ download_rizin ,
13
+ find_rizin_instance ,
14
+ get_rizin_version ,
15
+ remove_dup_list ,
16
+ update_rizin ,
17
+ )
13
18
14
19
15
20
@pytest .fixture (scope = "module" )
@@ -189,7 +194,8 @@ def test_fail_to_download_rizin_due_to_unavailable_network(tmp_path):
189
194
mock .side_effect = subprocess .CalledProcessError (
190
195
"1" ,
191
196
"mock command" ,
192
- stderr = b"fatal: unable to access 'https://github.com/rizinorg/rizin/'." ,
197
+ stderr = b"fatal: unable to access "
198
+ + "'https://github.com/rizinorg/rizin/'." ,
193
199
)
194
200
195
201
assert not download_rizin (target_path )
@@ -258,7 +264,8 @@ def test_find_rizin_instance_installed_in_quark_directory():
258
264
with patch (
259
265
"quark.utils.tools.get_rizin_version"
260
266
) as mocked_get_version :
261
- # Pretent the Rizin instance installed in the Quark directory is compatible.
267
+ # Pretent the Rizin instance installed in the Quark directory is
268
+ # compatible.
262
269
mocked_get_version .return_value = config .COMPATIBLE_RAZIN_VERSIONS [
263
270
0
264
271
]
@@ -269,8 +276,10 @@ def test_find_rizin_instance_installed_in_quark_directory():
269
276
== rizin_executable_path
270
277
)
271
278
272
- mocked_which .assert_called () # Must check the system path first.
273
- mocked_get_version .assert_called () # Must check the version of the instance in the Quark directory.
279
+ # Must check the system path first.
280
+ mocked_which .assert_called ()
281
+ # Must check the version of the instance in the Quark directory.
282
+ mocked_get_version .assert_called ()
274
283
275
284
276
285
def test_find_outdated_rizin_instance_installed_in_quark_directory (
@@ -287,7 +296,8 @@ def test_find_outdated_rizin_instance_installed_in_quark_directory(
287
296
with patch (
288
297
"quark.utils.tools.get_rizin_version"
289
298
) as mocked_get_version :
290
- # Pretent the Rizin instance installed in the Quark directory is not compatible.
299
+ # Pretent the Rizin instance installed in the Quark directory is
300
+ # not compatible.
291
301
mocked_get_version .return_value = "0.0.0"
292
302
293
303
with patch (
@@ -306,12 +316,17 @@ def test_find_outdated_rizin_instance_installed_in_quark_directory(
306
316
== rizin_executable_path
307
317
)
308
318
309
- mocked_which .assert_called () # Must check the system path first.
310
- mocked_get_version .assert_called () # Must check the version of the instance in the Quark directory.
319
+ # Must check the system path first.
320
+ mocked_which .assert_called ()
321
+ # Must check the version of the instance in the Quark
322
+ # directory.
323
+ mocked_get_version .assert_called ()
311
324
if disable_rizin_installation :
312
- mocked_update_rizin .assert_not_called () # Must not update the instance
325
+ # Must not update the instance
326
+ mocked_update_rizin .assert_not_called ()
313
327
else :
314
- mocked_update_rizin .assert_called () # Must update the instance to a compatible version
328
+ # Must update the instance to a compatible version
329
+ mocked_update_rizin .assert_called ()
315
330
316
331
317
332
_compatible_trigger = None
@@ -367,20 +382,27 @@ def test_find_broken_rizin_instance_installed_in_quark_directory(
367
382
)
368
383
if disable_rizin_installation :
369
384
# No Rizin instance exists
370
- assert result == None
385
+ assert result is None
371
386
else :
372
387
# Must use the instance in the Quark directory.
373
388
assert result == rizin_executable_path
374
389
375
- mocked_which .assert_called () # Must check the system path first.
376
- mocked_get_version .assert_called () # Must check the version of the instance in the Quark directory.
390
+ # Must check the system path first.
391
+ mocked_which .assert_called ()
392
+ # Must check the version of the instance in the Quark
393
+ # directory.
394
+ mocked_get_version .assert_called ()
377
395
378
396
if disable_rizin_installation :
379
- mocked_download_rizin .assert_not_called () # Must not download the source code.
380
- mocked_update_rizin .assert_not_called () # Must not update and compile a Rizin instance.
397
+ # Must not download the source code.
398
+ mocked_download_rizin .assert_not_called ()
399
+ # Must not update and compile a Rizin instance.
400
+ mocked_update_rizin .assert_not_called ()
381
401
else :
382
- mocked_download_rizin .assert_called () # Must download the source code.
383
- mocked_update_rizin .assert_called () # Must update and compile a Rizin instance.
402
+ # Must download the source code.
403
+ mocked_download_rizin .assert_called ()
404
+ # Must update and compile a Rizin instance.
405
+ mocked_update_rizin .assert_called ()
384
406
385
407
386
408
def test_find_rizin_instance_failed_to_download_the_source ():
@@ -394,7 +416,8 @@ def test_find_rizin_instance_failed_to_download_the_source():
394
416
with patch (
395
417
"quark.utils.tools.get_rizin_version"
396
418
) as mocked_get_version :
397
- # Pretent the Rizin instance installed in the Quark directory is broken.
419
+ # Pretent the Rizin instance installed in the Quark directory is
420
+ # broken.
398
421
mocked_get_version .return_value = None
399
422
400
423
with patch (
@@ -406,12 +429,16 @@ def test_find_rizin_instance_failed_to_download_the_source():
406
429
# Must use the instance in the Quark directory.
407
430
assert (
408
431
find_rizin_instance (rizin_source_path , target_commit )
409
- == None
432
+ is None
410
433
)
411
434
412
- mocked_which .assert_called () # Must check the system path first.
413
- mocked_get_version .assert_called () # Must check the version of the instance in the Quark directory.
414
- mocked_download_rizin .assert_called () # Must try to download the source code of the Rizin.
435
+ # Must check the system path first.
436
+ mocked_which .assert_called ()
437
+ # Must check the version of the instance in the Quark
438
+ # directory.
439
+ mocked_get_version .assert_called ()
440
+ # Must try to download the source code of the Rizin.
441
+ mocked_download_rizin .assert_called ()
415
442
416
443
417
444
def test_find_rizin_instance_failed_to_compile_or_update_the_source ():
@@ -425,7 +452,8 @@ def test_find_rizin_instance_failed_to_compile_or_update_the_source():
425
452
with patch (
426
453
"quark.utils.tools.get_rizin_version"
427
454
) as mocked_get_version :
428
- # Pretent the Rizin instance installed in the Quark directory is not compatible.
455
+ # Pretent the Rizin instance installed in the Quark directory is
456
+ # not compatible.
429
457
mocked_get_version .return_value = "0.0.0"
430
458
431
459
with patch (
@@ -437,9 +465,13 @@ def test_find_rizin_instance_failed_to_compile_or_update_the_source():
437
465
# Must use the instance in the Quark directory.
438
466
assert (
439
467
find_rizin_instance (rizin_source_path , target_commit )
440
- == None
468
+ is None
441
469
)
442
470
443
- mocked_which .assert_called () # Must check the system path first.
444
- mocked_get_version .assert_called () # Must check the version of the instance in the Quark directory.
445
- mocked_update_rizin .assert_called () # Must try to update and compile a Rizin instance.
471
+ # Must check the system path first.
472
+ mocked_which .assert_called ()
473
+ # Must check the version of the instance in the Quark
474
+ # directory.
475
+ mocked_get_version .assert_called ()
476
+ # Must try to update and compile a Rizin instance.
477
+ mocked_update_rizin .assert_called ()
0 commit comments