# Path: supplement/watcher.py
# class DummyMonitor(Monitor):
#     def __init__(self):
#         Monitor.__init__(self)
#         self.files = set()
# 
#     def _monitor(self, filename):
#         self.files.add(filename)
# 
#     def boo(self):
#         map(self.file_changed, self.files)


from supplement.watcher import DummyMonitor
    def change_on(fname, l):
        l.data.append(fname)

    changed1 = Holder()
    changed2 = Holder()

    watcher = DummyMonitor()
    watcher.monitor(fname, on_change, changed1)
    watcher.monitor(fname, on_change, changed1)
    watcher.monitor(fname, on_change, changed2)
    watcher.monitor(fname, change_on, changed2)

    watcher.boo()

    assert changed1.data == [fname]
    assert changed2.data == [fname, fname]

def test_watcher_must_call_uniq_method_handlers_on_file_change():
    fname = 'test.py'

    class Handler(object):
        def __init__(self):
            self.changed = []

        def on_change(self, filename):
            self.changed.append(filename)

    h1 = Handler()
    h2 = Handler()


# Path: supplement/watcher.py
# class DummyMonitor(Monitor):
#     def __init__(self):
#         Monitor.__init__(self)
#         self.files = set()
# 
#     def _monitor(self, filename):
#         self.files.add(filename)
# 
#     def boo(self):
#         map(self.file_changed, self.files)


# Path: tests/test_watcher.py
from supplement.watcher import DummyMonitor

    def change_on(fname, l):
        l.data.append(fname)

    changed1 = Holder()
    changed2 = Holder()

    watcher = DummyMonitor()
    watcher.monitor(fname, on_change, changed1)
    watcher.monitor(fname, on_change, changed1)
    watcher.monitor(fname, on_change, changed2)
    watcher.monitor(fname, change_on, changed2)

    watcher.boo()

    assert changed1.data == [fname]
    assert changed2.data == [fname, fname]

def test_watcher_must_call_uniq_method_handlers_on_file_change():
    fname = 'test.py'

    class Handler(object):
        def __init__(self):
            self.changed = []

        def on_change(self, filename):
            self.changed.append(filename)

    h1 = Handler()
    h2 = Handler()


    watcher = DummyMonitor()