Code Duplication    Length = 21-24 lines in 2 locations

tests/test_redis_lock.py 2 locations

@@ 487-510 (lines=24) @@
484
    assert unblocked.value == 1
485
486
487
def test_reset_all_signalizes(make_conn, make_process):
488
    """Call to reset_all() causes LPUSH to all signal keys, so blocked waiters
489
    become unblocked."""
490
    def workerfn(unblocked):
491
        conn = make_conn()
492
        lock1 = Lock(conn, 'lock1')
493
        lock2 = Lock(conn, 'lock2')
494
        if lock1.acquire() and lock2.acquire():
495
            unblocked.value = 1
496
497
    unblocked = multiprocessing.Value('B', 0)
498
    conn = make_conn()
499
    lock1 = Lock(conn, 'lock1')
500
    lock2 = Lock(conn, 'lock2')
501
    lock1.acquire()
502
    lock2.acquire()
503
504
    worker = make_process(target=workerfn, args=(unblocked,))
505
    worker.start()
506
    worker.join(0.5)
507
    reset_all(conn)
508
    worker.join(0.5)
509
510
    assert unblocked.value == 1
511
512
513
def test_auto_renewal_stops_after_gc(conn):
@@ 464-484 (lines=21) @@
461
    assert conn.llen('lock-signal:foo') == 0
462
463
464
def test_reset_signalizes(make_conn, make_process):
465
    """Call to reset() causes LPUSH to signal key, so blocked waiters
466
    become unblocked."""
467
    def workerfn(unblocked):
468
        conn = make_conn()
469
        lock = Lock(conn, 'lock')
470
        if lock.acquire():
471
            unblocked.value = 1
472
473
    unblocked = multiprocessing.Value('B', 0)
474
    conn = make_conn()
475
    lock = Lock(conn, 'lock')
476
    lock.acquire()
477
478
    worker = make_process(target=workerfn, args=(unblocked,))
479
    worker.start()
480
    worker.join(0.5)
481
    lock.reset()
482
    worker.join(0.5)
483
484
    assert unblocked.value == 1
485
486
487
def test_reset_all_signalizes(make_conn, make_process):