コード例 #1
0
def test_file_watch_os_error():
    cb = MagicMock()
    with make_file(b'test', 'csv') as fname:
        fw = df.FileWatcher(fname, cb)

    fw.check_for_changes()
    assert cb.call_count == 0
コード例 #2
0
ファイル: test_data_factories.py プロジェクト: dhomeier/glue
def test_file_watch_os_error():
    cb = MagicMock()
    with make_file(b'test', 'csv') as fname:
        fw = df.FileWatcher(fname, cb)

    with pytest.warns(UserWarning, match='Cannot access'):
        fw.check_for_changes()

    assert cb.call_count == 0
コード例 #3
0
def test_file_watch_os_error():
    cb = MagicMock()
    with make_file(b'test', 'csv') as fname:
        fw = df.FileWatcher(fname, cb)

    with warnings.catch_warnings(record=True) as w:
        fw.check_for_changes()
    assert len(w) == 1
    assert str(w[0].message).startswith('Cannot access')

    assert cb.call_count == 0
コード例 #4
0
def test_file_watch():
    cb = MagicMock()
    with make_file(b'test', 'csv') as fname:
        fw = df.FileWatcher(fname, cb)
        fw.check_for_changes()
        assert cb.call_count == 0

        # fudge stat_cache to simulate filechange
        # we could just change the file, but
        # the underlying OS check has low time resolution
        # and would require a sleep
        fw.stat_cache -= 1

        fw.check_for_changes()
        assert cb.call_count == 1