def test_pycremoval(self, tmpdir): tmp = tmpdir hello = tmp.ensure("hello.py") sd = StatRecorder([tmp]) changed = sd.check() assert not changed pycfile = hello + "c" pycfile.ensure() hello.write("world") changed = sd.check() assert changed assert not pycfile.check()
def test_pycremoval(self, tmp_path: Path) -> None: tmp = tmp_path hello = tmp / "hello.py" hello.touch() sd = StatRecorder([py.path.local(tmp)]) changed = sd.check() assert not changed pycfile = hello.with_suffix(".pyc") pycfile.touch() hello.write_text("world") changed = sd.check() assert changed assert not pycfile.exists()
def test_filechange_deletion_race(self, tmpdir, monkeypatch): tmp = tmpdir sd = StatRecorder([tmp]) changed = sd.check() assert not changed p = tmp.ensure("new.py") changed = sd.check() assert changed p.remove() # make check()'s visit() call return our just removed # path as if we were in a race condition monkeypatch.setattr(tmp, "visit", lambda *args: [p]) changed = sd.check() assert changed
def test_filechange_deletion_race(self, tmpdir, monkeypatch): tmp = tmpdir sd = StatRecorder([tmp]) changed = sd.check() assert not changed p = tmp.ensure("new.py") changed = sd.check() assert changed p.remove() # make check()'s visit() call return our just removed # path as if we were in a race condition monkeypatch.setattr(tmp, 'visit', lambda *args: [p]) changed = sd.check() assert changed
def test_filechange_deletion_race(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: tmp = tmp_path pytmp = py.path.local(tmp) sd = StatRecorder([pytmp]) changed = sd.check() assert not changed p = tmp.joinpath("new.py") p.touch() changed = sd.check() assert changed p.unlink() # make check()'s visit() call return our just removed # path as if we were in a race condition monkeypatch.setattr(pytmp, "visit", lambda *args: [py.path.local(p)]) changed = sd.check() assert changed
def test_filechange(self, tmp_path: Path) -> None: tmp = tmp_path hello = tmp / "hello.py" hello.touch() sd = StatRecorder([py.path.local(tmp)]) changed = sd.check() assert not changed hello.write_text("world") changed = sd.check() assert changed hello.with_suffix(".pyc").write_text("hello") changed = sd.check() assert not changed p = tmp / "new.py" p.touch() changed = sd.check() assert changed p.unlink() changed = sd.check() assert changed tmp.joinpath("a", "b").mkdir(parents=True) tmp.joinpath("a", "b", "c.py").touch() changed = sd.check() assert changed tmp.joinpath("a", "c.txt").touch() changed = sd.check() assert changed changed = sd.check() assert not changed shutil.rmtree(str(tmp.joinpath("a"))) changed = sd.check() assert changed
def test_filechange(self, tmpdir): tmp = tmpdir hello = tmp.ensure("hello.py") sd = StatRecorder([tmp]) changed = sd.check() assert not changed hello.write("world") changed = sd.check() assert changed (hello + "c").write("hello") changed = sd.check() assert not changed p = tmp.ensure("new.py") changed = sd.check() assert changed p.remove() changed = sd.check() assert changed tmp.join("a", "b", "c.py").ensure() changed = sd.check() assert changed tmp.join("a", "c.txt").ensure() changed = sd.check() assert changed changed = sd.check() assert not changed tmp.join("a").remove() changed = sd.check() assert changed
def test_filechange(self, tmpdir): tmp = tmpdir hello = tmp.ensure("hello.py") sd = StatRecorder([tmp]) changed = sd.check() assert not changed hello.write("world") changed = sd.check() assert changed (hello + "c").write("hello") changed = sd.check() assert changed p = tmp.ensure("new.py") changed = sd.check() assert changed p.remove() changed = sd.check() assert changed tmp.join("a", "b", "c.py").ensure() changed = sd.check() assert changed tmp.join("a", "c.txt").ensure() changed = sd.check() assert changed changed = sd.check() assert not changed tmp.join("a").remove() changed = sd.check() assert changed