Coding style.

- Since there is only one display, appearance_changed_event can be
  a module level global in fill3.
- Remove all the appearance_changed_event plumbing.
This commit is contained in:
Andrew Hamilton 2021-11-29 15:57:16 +10:00
parent 71b9da128b
commit 4150a9a250
5 changed files with 55 additions and 76 deletions

View file

@ -50,11 +50,9 @@ class ScreenWidgetTestCase(unittest.TestCase):
foo_path = os.path.join(project_dir, "foo.py")
_touch(foo_path)
jobs_added_event = asyncio.Event()
appearance_changed_event = asyncio.Event()
summary = __main__.Summary(project_dir, jobs_added_event)
log = __main__.Log(appearance_changed_event)
self.main_widget = __main__.Screen(
summary, log, appearance_changed_event, _MockMainLoop())
log = __main__.Log()
self.main_widget = __main__.Screen(summary, log, _MockMainLoop())
def tearDown(self):
shutil.rmtree(self.temp_dir)
@ -123,20 +121,17 @@ class SummarySyncWithFilesystemTestCase(unittest.TestCase):
self.bar_path = os.path.join(self.temp_dir, "bar.md")
self.zoo_path = os.path.join(self.temp_dir, "zoo.html")
self.jobs_added_event = asyncio.Event()
self.appearance_changed_event = asyncio.Event()
self.summary = __main__.Summary(self.temp_dir, self.jobs_added_event)
self.loop = asyncio.new_event_loop()
def callback(event):
__main__.on_filesystem_event(event, self.summary, self.temp_dir,
self.appearance_changed_event)
__main__.on_filesystem_event(event, self.summary, self.temp_dir)
__main__.setup_inotify(self.temp_dir, self.loop, callback,
__main__.is_path_excluded)
_touch(self.foo_path)
_touch(self.bar_path)
self.log = __main__.Log(self.appearance_changed_event)
self.loop.run_until_complete(self.summary.sync_with_filesystem(
self.appearance_changed_event, self.log))
self.log = __main__.Log()
self.loop.run_until_complete(self.summary.sync_with_filesystem(self.log))
self.jobs_added_event.clear()
def tearDown(self):
@ -188,9 +183,8 @@ class SummarySyncWithFilesystemTestCase(unittest.TestCase):
baz_path = os.path.join(self.temp_dir, "baz")
os.symlink(self.foo_path, baz_path)
os.link(self.foo_path, self.zoo_path)
log = __main__.Log(self.appearance_changed_event)
self.loop.run_until_complete(self.summary.sync_with_filesystem(
self.appearance_changed_event, log))
log = __main__.Log()
self.loop.run_until_complete(self.summary.sync_with_filesystem(log))
self._assert_paths(["./bar.md", "./baz", "./foo", "./zoo.html"])
self.assertTrue(id(self.summary._entries[1]) != # baz
id(self.summary._entries[2])) # foo