Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_text_spinner_color(self):
"""Test basic spinner with available colors color (both spinner and text)
"""
for color, color_int in COLORS.items():
self._stream_file = os.path.join(self.TEST_FOLDER, 'test.txt')
self._stream = io.open(self._stream_file, 'w+')
spinner = Halo(
text='foo',
text_color=color,
color=color,
spinner='dots',
stream=self._stream
)
spinner.start()
time.sleep(1)
spinner.stop()
output = self._get_test_output()['colors']
def test_text_spinner_color(self):
"""Test basic spinner with available colors color (both spinner and text)
"""
for color, color_int in COLORS.items():
spinner = HaloNotebook(text='foo', text_color=color, color=color, spinner='dots')
spinner.start()
time.sleep(1)
output = self._get_test_output(spinner)['colors']
spinner.stop()
# check if spinner colors match
self.assertEqual(color_int, int(output[0][0]))
self.assertEqual(color_int, int(output[1][0]))
self.assertEqual(color_int, int(output[2][0]))
# check if text colors match
self.assertEqual(color_int, int(output[0][1]))
self.assertEqual(color_int, int(output[1][1]))
self.assertEqual(color_int, int(output[2][1]))
def test_spinner_color(self):
"""Test ANSI escape characters are present
"""
for color, color_int in COLORS.items():
self._stream = io.open(self._stream_file, 'w+') # reset stream
spinner = Halo(color=color, stream=self._stream)
spinner.start()
spinner.stop()
output = self._get_test_output(no_ansi=False)
output_merged = [arr for c in output['colors'] for arr in c]
self.assertEquals(str(color_int) in output_merged, True)