From ca54911481368ff16ccf61f2acdda0f39989b778 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 7 Oct 2013 10:28:08 +0200 Subject: [PATCH] ignore directories and pyc files for changes (editors write tmp/swap files etc., which also affects mtime of directory) --- CHANGELOG | 4 +++- testing/test_looponfail.py | 12 ++++++++---- xdist/looponfail.py | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6d5e4a5..ca34174 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,9 @@ 1.10 ------------------------- -- ignore dot files for file changes (editors write tmp/swap files etc.) +- ignore pyc files, dot files and directories for changes (editors write tmp/swap + files etc., which also affects mtime of directory) + 1.9 ------------------------- diff --git a/testing/test_looponfail.py b/testing/test_looponfail.py index 38f4963..4112f04 100644 --- a/testing/test_looponfail.py +++ b/testing/test_looponfail.py @@ -16,7 +16,7 @@ class TestStatRecorder: (hello + "c").write("hello") changed = sd.check() - assert changed + assert not changed p = tmp.ensure("new.py") changed = sd.check() @@ -40,6 +40,12 @@ class TestStatRecorder: changed = sd.check() assert changed + def test_dirchange(self, tmpdir): + tmp = tmpdir + hello = tmp.ensure("dir", "hello.py") + sd = StatRecorder([tmp]) + assert not sd.fil(tmp.join("dir")) + def test_filechange_deletion_race(self, tmpdir, monkeypatch): tmp = tmpdir sd = StatRecorder([tmp]) @@ -67,12 +73,10 @@ class TestStatRecorder: pycfile = hello + "c" pycfile.ensure() - changed = sd.check() - assert changed - hello.write("world") changed = sd.check() assert changed + assert not pycfile.check() def test_waitonchange(self, tmpdir, monkeypatch): tmp = tmpdir diff --git a/xdist/looponfail.py b/xdist/looponfail.py index d43954d..f71ffef 100644 --- a/xdist/looponfail.py +++ b/xdist/looponfail.py @@ -188,7 +188,7 @@ class StatRecorder: self.check() # snapshot state def fil(self, p): - return p.check(dotfile=0) + return p.check(file=1, dotfile=0) and p.ext != ".pyc" def rec(self, p): return p.check(dotfile=0)