forked from bpython/bpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_filewatch.py
More file actions
33 lines (24 loc) · 982 Bytes
/
test_filewatch.py
File metadata and controls
33 lines (24 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# encoding: utf-8
import os
try:
import watchdog
from bpython.curtsiesfrontend.filewatch import ModuleChangedEventHandler
has_watchdog = True
except ImportError:
has_watchdog = False
from bpython.test import mock, unittest
@unittest.skipUnless(has_watchdog, "watchdog required")
class TestModuleChangeEventHandler(unittest.TestCase):
def setUp(self):
self.module = ModuleChangedEventHandler([], 1)
self.module.observer = mock.Mock()
def test_create_module_handler(self):
self.assertIsInstance(self.module, ModuleChangedEventHandler)
def test_add_module(self):
self.module._add_module('something/test.py')
self.assertIn(os.path.abspath('something/test'),
self.module.dirs[os.path.abspath('something')])
def test_activate_throws_error_when_already_activated(self):
self.module.activated = True
with self.assertRaises(ValueError):
self.module.activate()