Commit ccb2ef41 authored by Pierre-Elliott Bécue's avatar Pierre-Elliott Bécue

d/p/0002: Sorry attempt to fix a failing test.

See the patch notes to get a clearer intel.  Also see
parent 8a767187
Pipeline #57160 failed
python-livereload (2.6.1-2) unstable; urgency=medium
* d/p/0002: Sorry attempt to fix a failing test. See the patch notes to get
a clearer intel. Also see
-- Pierre-Elliott Bécue <> Sat, 20 Jul 2019 20:36:14 +0200
python-livereload (2.6.1-1) unstable; urgency=medium
* New upstream release 2.6.1
From: =?utf-8?q?Pierre-Elliott_B=C3=A9cue?= <>
Date: Sat, 20 Jul 2019 20:34:15 +0200
Subject: Sleep before modifying first_path otherwise the mtime isn't updated
It seems that the mtime handling by python acts weirdly.
First, as this snippet shows, the mtime is lower than the initial time
although the file got modified after.
import os
import time
def test_mtime():
_s = time.time()
with open("/tmp/test", "w") as testfile:
_t = os.path.getmtime("/tmp/test")
In [4]: test_mtime()
Second, as this snippet shows, it doesn't update in each and every
In [35]: def test_mtime():
...: with open("/tmp/test_mtime", "w") as myfile:
...: myfile.write("")
...: print(repr(os.path.getmtime("/tmp/test_mtime")))
...: time.sleep(1)
...: with open("/tmp/test_mtime", "a") as myfile:
...: myfile.write("")
...: os.sync()
...: time.sleep(1)
...: print(repr(os.path.getmtime("/tmp/test_mtime")))
In [36]: test_mtime()
Sleeping right before the file modification in the test seems enough,
but it's a messy solution. The bug has been reported upstream, and
upstream should consider relying definitely on pyinotify instead of
trying to do something with a custom class.
tests/ | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/ b/tests/
index a91029f..3f48b13 100644
--- a/tests/
+++ b/tests/
@@ -144,6 +144,8 @@ class TestWatcher(unittest.TestCase):
assert watcher.examine() == (second_path, None)
assert watcher.examine() == (None, None)
+ # Without a sufficient wait, the mtime isn't updated...
+ time.sleep(1)
with open(first_path, 'a') as f:
assert watcher.examine() == (first_path, None)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment