Skip to content

Commit fa4835f

Browse files
committed
Add test case for multiple spinner
1 parent aaa1904 commit fa4835f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/test_halo.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,26 @@ def test_redirect_stdout(self):
622622

623623
self.assertIn('foo', output[0])
624624

625+
def test_running_multiple_instances(self):
626+
spinner = Halo("foo", stream=self._stream)
627+
_instance = Halo()
628+
# Pretend that another spinner is being displayed under spinner
629+
_instance._content = "Some lines\n"
630+
Halo._instances.extend([spinner, _instance])
631+
spinner.start()
632+
time.sleep(1)
633+
spinner.stop()
634+
spinner.stop_and_persist(text="Done")
635+
output = self._get_test_output()["text"]
636+
self.assertEqual(output[0], "{} foo".format(frames[0]))
637+
self.assertEqual(output[1], "Some lines")
638+
self.assertEqual(output[2], "{} foo".format(frames[1]))
639+
self.assertEqual(output[3], "Some lines")
640+
self.assertEqual(output[-2], " Done")
641+
self.assertEqual(output[-1], "Some lines")
642+
625643
def tearDown(self):
626-
pass
644+
self._stream.close()
627645

628646

629647
if __name__ == '__main__':

0 commit comments

Comments
 (0)