Skip to content

Commit

Permalink
test: UrwidImageScreen: Reoganize and rename tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymouX47 committed Dec 29, 2023
1 parent 5d548a4 commit 2f020d3
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions tests/widget/urwid/test_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,53 @@
trans = BlockImage.from_file("tests/images/trans.png")


class TestScreen:
class TestStartStop:
def test_supported(self):
buf = io.StringIO()
screen = UrwidImageScreen(sys.__stdin__, buf)
class TestStartStop:
def test_supported(self):
buf = io.StringIO()
screen = UrwidImageScreen(sys.__stdin__, buf)

screen.start()
start_output = buf.getvalue()
buf.seek(0)
buf.truncate()
screen.stop()
stop_output = buf.getvalue()

assert start_output.endswith(ctlseqs.KITTY_DELETE_ALL)
assert stop_output.startswith(ctlseqs.KITTY_DELETE_ALL)

def test_not_supported(self):
buf = io.StringIO()
screen = UrwidImageScreen(sys.__stdin__, buf)

KittyImage._supported = False
try:
screen.start()
start_output = buf.getvalue()
buf.seek(0)
buf.truncate()
screen.stop()
stop_output = buf.getvalue()

assert start_output.endswith(ctlseqs.KITTY_DELETE_ALL)
assert stop_output.startswith(ctlseqs.KITTY_DELETE_ALL)
assert ctlseqs.KITTY_DELETE_ALL not in start_output
assert ctlseqs.KITTY_DELETE_ALL not in stop_output
finally:
KittyImage._supported = True

def test_not_supported(self):
buf = io.StringIO()
screen = UrwidImageScreen(sys.__stdin__, buf)

KittyImage._supported = False
try:
screen.start()
start_output = buf.getvalue()
buf.seek(0)
buf.truncate()
screen.stop()
stop_output = buf.getvalue()

assert ctlseqs.KITTY_DELETE_ALL not in start_output
assert ctlseqs.KITTY_DELETE_ALL not in stop_output
finally:
KittyImage._supported = True

def test_synced_output(self):
widget = urwid.SolidFill("x")
buf = io.StringIO()
screen = UrwidImageScreen(sys.__stdin__, buf)
screen.start()
def test_synced_output():
widget = urwid.SolidFill("x")
buf = io.StringIO()
screen = UrwidImageScreen(sys.__stdin__, buf)
screen.start()

buf.seek(0)
buf.truncate()
screen.draw_screen(_size, widget.render(_size))
output = buf.getvalue()
buf.seek(0)
buf.truncate()
screen.draw_screen(_size, widget.render(_size))
output = buf.getvalue()

assert output.startswith(ctlseqs.BEGIN_SYNCED_UPDATE)
assert output.endswith(ctlseqs.END_SYNCED_UPDATE)
assert output.startswith(ctlseqs.BEGIN_SYNCED_UPDATE)
assert output.endswith(ctlseqs.END_SYNCED_UPDATE)


buf = io.StringIO()
Expand All @@ -94,7 +94,7 @@ def setup_clear_buffers():
urwid.write_tty = write_tty


class TestScreenClearImages:
class TestClearImages:
class TestNowFalse:
def test_single(self):
image_ws = [UrwidImage(kitty_image) for _ in range(4)]
Expand Down Expand Up @@ -239,7 +239,7 @@ def test_disguise_state_all(self):
)


class TestScreenAutoClearImages:
class TestAutoClearImages:
def test_image_cviews(self):
assert screen._ti_image_cviews == frozenset()
screen.draw_screen(_size, widget.render(_size))
Expand Down

0 comments on commit 2f020d3

Please sign in to comment.