コード例 #1
0
    def test_waitonchange(self, tmpdir, monkeypatch):
        tmp = tmpdir
        sd = StatRecorder([tmp])

        l = [True, False]
        monkeypatch.setattr(StatRecorder, 'check', lambda self: l.pop())
        sd.waitonchange(checkinterval=0.2)
        assert not l
コード例 #2
0
ファイル: test_looponfail.py プロジェクト: ohmu/pytest-xdist
    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()
コード例 #3
0
    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
コード例 #4
0
    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
コード例 #5
0
    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
コード例 #6
0
    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
コード例 #7
0
    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
コード例 #8
0
 def test_dirchange(self, tmpdir):
     tmp = tmpdir
     tmp.ensure("dir", "hello.py")
     sd = StatRecorder([tmp])
     assert not sd.fil(tmp.join("dir"))
コード例 #9
0
 def test_dirchange(self, tmp_path: Path) -> None:
     tmp = tmp_path
     tmp.joinpath("dir").mkdir()
     tmp.joinpath("dir", "hello.py").touch()
     sd = StatRecorder([py.path.local(tmp)])
     assert not sd.fil(py.path.local(tmp / "dir"))
コード例 #10
0
    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
コード例 #11
0
ファイル: test_looponfail.py プロジェクト: ohmu/pytest-xdist
 def test_dirchange(self, tmpdir):
     tmp = tmpdir
     tmp.ensure("dir", "hello.py")
     sd = StatRecorder([tmp])
     assert not sd.fil(tmp.join("dir"))