Skip to content

Commit

Permalink
Add test case for multiple spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Oct 30, 2020
1 parent f1a95c3 commit a34da90
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/test_halo.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,26 @@ def test_redirect_stdout(self):

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

def test_running_multiple_instances(self):
spinner = Halo("foo", stream=self._stream)
_instance = Halo()
# Pretend that another spinner is being displayed under spinner
_instance._content = "Some lines\n"
Halo._instances.extend([spinner, _instance])
spinner.start()
time.sleep(1)
spinner.stop()
spinner.stop_and_persist(text="Done")
output = self._get_test_output()["text"]
self.assertEqual(output[0], "{} foo".format(frames[0]))
self.assertEqual(output[1], "Some lines")
self.assertEqual(output[2], "{} foo".format(frames[1]))
self.assertEqual(output[3], "Some lines")
self.assertEqual(output[-2], " Done")
self.assertEqual(output[-1], "Some lines")

def tearDown(self):
pass
self._stream.close()


if __name__ == '__main__':
Expand Down

0 comments on commit a34da90

Please sign in to comment.