mirror of
https://github.com/powerline/powerline.git
synced 2025-07-27 07:44:36 +02:00
Use monotonic() in place of time.time()
This commit is contained in:
parent
b1dba59170
commit
68a6fd056c
@ -1,11 +1,15 @@
|
|||||||
# vim:fileencoding=utf-8:noet
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
from powerline.lib import mergedicts, add_divider_highlight_group
|
from powerline.lib import mergedicts, add_divider_highlight_group
|
||||||
from powerline.lib.humanize_bytes import humanize_bytes
|
from powerline.lib.humanize_bytes import humanize_bytes
|
||||||
from powerline.lib.vcs import guess
|
from powerline.lib.vcs import guess
|
||||||
from subprocess import call, PIPE
|
from powerline.lib.monotonic import monotonic
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
from time import sleep
|
||||||
|
from subprocess import call, PIPE
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from tests import TestCase, SkipTest
|
from tests import TestCase, SkipTest
|
||||||
|
|
||||||
@ -41,12 +45,11 @@ class TestLib(TestCase):
|
|||||||
|
|
||||||
class TestFilesystemWatchers(TestCase):
|
class TestFilesystemWatchers(TestCase):
|
||||||
def do_test_for_change(self, watcher, path):
|
def do_test_for_change(self, watcher, path):
|
||||||
import time
|
st = monotonic()
|
||||||
st = time.time()
|
while monotonic() - st < 1:
|
||||||
while time.time() - st < 1:
|
|
||||||
if watcher(path):
|
if watcher(path):
|
||||||
return
|
return
|
||||||
time.sleep(0.1)
|
sleep(0.1)
|
||||||
self.fail('The change to {0} was not detected'.format(path))
|
self.fail('The change to {0} was not detected'.format(path))
|
||||||
|
|
||||||
def test_file_watcher(self):
|
def test_file_watcher(self):
|
||||||
@ -134,9 +137,8 @@ use_mercurial = use_bzr = sys.version_info < (3, 0)
|
|||||||
|
|
||||||
class TestVCS(TestCase):
|
class TestVCS(TestCase):
|
||||||
def do_branch_rename_test(self, repo, q):
|
def do_branch_rename_test(self, repo, q):
|
||||||
import time
|
st = monotonic()
|
||||||
st = time.time()
|
while monotonic() - st < 1:
|
||||||
while time.time() - st < 1:
|
|
||||||
# Give inotify time to deliver events
|
# Give inotify time to deliver events
|
||||||
ans = repo.branch()
|
ans = repo.branch()
|
||||||
if hasattr(q, '__call__'):
|
if hasattr(q, '__call__'):
|
||||||
@ -145,7 +147,7 @@ class TestVCS(TestCase):
|
|||||||
else:
|
else:
|
||||||
if ans == q:
|
if ans == q:
|
||||||
break
|
break
|
||||||
time.sleep(0.01)
|
sleep(0.01)
|
||||||
if hasattr(q, '__call__'):
|
if hasattr(q, '__call__'):
|
||||||
self.assertTrue(q(ans))
|
self.assertTrue(q(ans))
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user