Make sure watcher is not used

This commit is contained in:
ZyX 2013-11-21 00:23:25 +04:00
parent 95d13a334a
commit bb0d9028f1
2 changed files with 10 additions and 8 deletions

View File

@ -62,7 +62,6 @@ class Watcher(object):
return True
return False
@log_call
def _reset(self, files):
with self.lock:
self.events.clear()
@ -112,13 +111,16 @@ renderer = SimpleRenderer
def get_powerline(**kwargs):
return TestPowerline(
watcher = Watcher()
pl = TestPowerline(
ext='test',
renderer_module='tests.lib.config_mock',
logger=Logger(),
config_loader=ConfigLoader(load=load_json_config, watcher=Watcher(), run_once=kwargs.get('run_once')),
config_loader=ConfigLoader(load=load_json_config, watcher=watcher, run_once=kwargs.get('run_once')),
**kwargs
)
pl._watcher = watcher
return pl
config_container = None

View File

@ -97,10 +97,7 @@ def sleep(interval):
def add_watcher_events(p, *args, **kwargs):
try:
p.config_loader.watcher._reset(args)
except AttributeError:
return
p._watcher._reset(args)
while not p._will_create_renderer():
sleep(kwargs.get('interval', 0.000001))
if not kwargs.get('wait', True):
@ -121,6 +118,7 @@ class TestConfigReload(TestCase):
# When running once thread should not start
self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
self.assertAccessEvents()
self.assertEqual(p.logger._pop_msgs(), [])
# Without the following assertion test_reload_colors may fail for
# unknown reason (with AssertionError telling about “config” accessed
# one more time then needed)
@ -255,7 +253,7 @@ class TestConfigReload(TestCase):
self.assertEqual(p.render(), '<1 2 1> col3<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
self.assertAccessEvents('themes/test/default')
self.assertEqual(p.logger._pop_msgs(), [])
self.assertTrue(p.config_loader.watcher._calls)
self.assertTrue(p._watcher._calls)
pop_events()
def test_run_once_no_theme_reload(self):
@ -269,6 +267,8 @@ class TestConfigReload(TestCase):
add_watcher_events(p, 'themes/test/default', wait=False)
self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
self.assertAccessEvents()
self.assertEqual(p.logger._pop_msgs(), [])
self.assertEqual(p._watcher._calls, [])
pop_events()