summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_threadsignals.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-12-17 08:36:36 (GMT)
committerGitHub <noreply@github.com>2018-12-17 08:36:36 (GMT)
commit2cf4c202ffeb30787c944365ba54013688b854c2 (patch)
treeaa98e69de819cb1cd0f5bd25fb10636f98001ff2 /Lib/test/test_threadsignals.py
parent4e80f5cbeaee87a26e49bc9623c92a10e28dbbd9 (diff)
downloadcpython-2cf4c202ffeb30787c944365ba54013688b854c2.zip
cpython-2cf4c202ffeb30787c944365ba54013688b854c2.tar.gz
cpython-2cf4c202ffeb30787c944365ba54013688b854c2.tar.bz2
bpo-35513: Replace time.time() with time.monotonic() in tests (GH-11182)
Replace time.time() with time.monotonic() in tests to measure time delta. test_zipfile64: display progress every minute (60 secs) rather than every 5 minutes (5*60 seconds).
Diffstat (limited to 'Lib/test/test_threadsignals.py')
-rw-r--r--Lib/test/test_threadsignals.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/test/test_threadsignals.py b/Lib/test/test_threadsignals.py
index 7e13b17..eeacd36 100644
--- a/Lib/test/test_threadsignals.py
+++ b/Lib/test/test_threadsignals.py
@@ -95,9 +95,9 @@ class ThreadSignals(unittest.TestCase):
lock = thread.allocate_lock()
lock.acquire()
signal.alarm(1)
- t1 = time.time()
+ t1 = time.monotonic()
self.assertRaises(KeyboardInterrupt, lock.acquire, timeout=5)
- dt = time.time() - t1
+ dt = time.monotonic() - t1
# Checking that KeyboardInterrupt was raised is not sufficient.
# We want to assert that lock.acquire() was interrupted because
# of the signal, not that the signal handler was called immediately
@@ -136,9 +136,9 @@ class ThreadSignals(unittest.TestCase):
rlock.release()
time.sleep(0.01)
signal.alarm(1)
- t1 = time.time()
+ t1 = time.monotonic()
self.assertRaises(KeyboardInterrupt, rlock.acquire, timeout=5)
- dt = time.time() - t1
+ dt = time.monotonic() - t1
# See rationale above in test_lock_acquire_interruption
self.assertLess(dt, 3.0)
finally:
@@ -203,9 +203,9 @@ class ThreadSignals(unittest.TestCase):
old_handler = signal.signal(signal.SIGUSR1, my_handler)
try:
def timed_acquire():
- self.start = time.time()
+ self.start = time.monotonic()
lock.acquire(timeout=0.5)
- self.end = time.time()
+ self.end = time.monotonic()
def send_signals():
for _ in range(40):
time.sleep(0.02)