Coding style.

- More import tidying.
- Fix line lengths.
- Dead code in tests.
- lambdas.
- Tests pass regardless of term type.
This commit is contained in:
Andrew Hamilton 2021-11-22 19:53:37 +10:00
parent 2d9a475833
commit d1e538f5f3
11 changed files with 177 additions and 43 deletions

View file

@ -9,14 +9,13 @@ import shutil
import tempfile
import unittest
os.environ["TERM"] = "xterm-256color"
import fill3
import golden
import eris.__main__ as __main__
os.environ["TERM"] = "xterm-256color"
_DIMENSIONS = (100, 60)
@ -68,18 +67,15 @@ class ScreenWidgetTestCase(unittest.TestCase):
_assert_widget_appearance(self.main_widget, "golden-files/help")
def test_log_appearance(self):
log_shown = _widget_to_string(self.main_widget)
_assert_widget_appearance(self.main_widget,
"golden-files/log-original")
self.main_widget.toggle_log()
log_hidden = _widget_to_string(self.main_widget)
actual = "shown:\n%s\nhidden:\n%s" % (log_shown, log_hidden)
_assert_widget_appearance(self.main_widget, "golden-files/log")
def test_window_orientation(self):
window_left_right = _widget_to_string(self.main_widget)
_assert_widget_appearance(self.main_widget,
"golden-files/window-orientation-original")
self.main_widget.toggle_window_orientation()
window_top_bottom = _widget_to_string(self.main_widget)
actual = ("left-right:\n%s\ntop-bottom:\n%s" %
(window_left_right, window_top_bottom))
_assert_widget_appearance(self.main_widget,
"golden-files/window-orientation")
@ -130,8 +126,10 @@ class SummarySyncWithFilesystemTestCase(unittest.TestCase):
self.appearance_changed_event = asyncio.Event()
self.summary = __main__.Summary(self.temp_dir, self.jobs_added_event)
self.loop = asyncio.new_event_loop()
callback = lambda event: __main__.on_filesystem_event(
event, self.summary, self.temp_dir, self.appearance_changed_event)
def callback(event):
__main__.on_filesystem_event(event, self.summary, self.temp_dir,
self.appearance_changed_event)
__main__.setup_inotify(self.temp_dir, self.loop, callback,
__main__.is_path_excluded)
_touch(self.foo_path)

View file

@ -0,0 +1,60 @@
┏━━━━━━━━ Summary of project ━━━━━━━━┓┌────────────────────────────────────────────────────────────┐
┃ ┃│Nothing selected │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛│ │
┌─────────────── Log ────────────────┐│ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
└────────────────────────────────────┘└────────────────────────────────────────────────────────────┘
 help quit tab:focus turn log edit next sort refresh fullscreen open 

View file

@ -0,0 +1,60 @@
┏━━━━━━━━ Summary of project ━━━━━━━━┓┌────────────────────────────────────────────────────────────┐
┃ ┃│Nothing selected │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┃ ┃│ │
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛│ │
┌─────────────── Log ────────────────┐│ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
│ ││ │
└────────────────────────────────────┘└────────────────────────────────────────────────────────────┘
 help quit tab:focus turn log edit next sort refresh fullscreen open 

View file

@ -11,7 +11,7 @@ import eris.paged_list as paged_list
class PagedListTestCase(unittest.TestCase):
def test_batch(self):
self.assertEqual(list(paged_list.batch(iter([3,4,5,6,7]), 2)),
self.assertEqual(list(paged_list.batch(iter([3, 4, 5, 6, 7]), 2)),
[[3, 4], [5, 6], [7]])
def test_getitem(self):

View file

@ -7,14 +7,13 @@ import shutil
import unittest
import unittest.mock
os.environ["TERM"] = "xterm-256color"
import fill3
import golden
import eris.tools as tools
os.environ["TERM"] = "xterm-256color"
os.environ["TZ"] = "GMT"
ERIS_ROOT = os.path.dirname(__file__)