Skip to content

Commit

Permalink
Merge branch 'feature/keyboardinterrupt' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
solarnz committed Jun 9, 2014
2 parents 87a2f29 + ef8054b commit 539671e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
6 changes: 0 additions & 6 deletions README.rst
Expand Up @@ -49,9 +49,3 @@ Usage
.. code-block:: bash
nosetests --with-watcher
Documentation
-------------

More documentation can be found at
`ReadTheDocs <http://nose-watcher.rtfd.org>`_
6 changes: 5 additions & 1 deletion nose_watcher/nose_watcher.py
Expand Up @@ -61,7 +61,11 @@ def finalize(self, result):
self.print_status()

while True:
events = poll.poll(timeout)
try:
events = poll.poll(timeout)
except KeyboardInterrupt:
return

files = set()

if threshold() or not events:
Expand Down
32 changes: 20 additions & 12 deletions tests/test_nose_watcher.py
Expand Up @@ -50,10 +50,10 @@ def test_argument_parsing_from_sys_argv(self):
)


@patch('inotify.watcher.AutoWatcher')
@patch('inotify.watcher.Threshold')
@patch('select.poll')
class TestWatching(TestNoseWatcher):
@patch('inotify.watcher.AutoWatcher')
@patch('inotify.watcher.Threshold')
@patch('select.poll')
def test_watch_no_files_modified(self, poll_mock, threshold_patch,
watcher_mock):
threshold = Mock()
Expand All @@ -63,9 +63,6 @@ def test_watch_no_files_modified(self, poll_mock, threshold_patch,

self.assertFalse(self.plugin.call.called)

@patch('inotify.watcher.AutoWatcher')
@patch('inotify.watcher.Threshold')
@patch('select.poll')
def test_watch_no_files_watched(self, poll_mock, threshold_patch,
watcher_mock):
threshold = Mock()
Expand All @@ -80,9 +77,6 @@ def test_watch_no_files_watched(self, poll_mock, threshold_patch,

self.assertFalse(self.plugin.call.called)

@patch('inotify.watcher.AutoWatcher')
@patch('inotify.watcher.Threshold')
@patch('select.poll')
def test_watch_python_files_modified(self, poll_mock, threshold_patch,
watcher_mock):
threshold = Mock()
Expand All @@ -100,9 +94,6 @@ def test_watch_python_files_modified(self, poll_mock, threshold_patch,

self.assertTrue(self.plugin.call.called)

@patch('inotify.watcher.AutoWatcher')
@patch('inotify.watcher.Threshold')
@patch('select.poll')
def test_watch_text_files_modified(self, poll_mock, threshold_patch,
watcher_mock):
threshold = Mock()
Expand All @@ -119,3 +110,20 @@ def test_watch_text_files_modified(self, poll_mock, threshold_patch,
self.plugin.finalize(None)

self.assertFalse(self.plugin.call.called)

def test_watch_keyboard_interrupt(self, poll_mock, threshold_patch,
watcher_mock):
threshold = Mock()
threshold_patch.return_value = threshold
threshold.return_value = True

watcher = Mock()
watcher_mock.return_value = watcher

poll = Mock()
poll_mock.return_value = poll
poll.poll.side_effect = KeyboardInterrupt

self.plugin.finalize(None)

self.assertFalse(self.plugin.call.called)

0 comments on commit 539671e

Please sign in to comment.