def test_length_when_should_be_static(self, mock_print, mock_sleep): l = len(self.test_str) + 2 c = 2 args = scroller.parser.parse_args( ['-l', str(l), '-c', str(c), '-s', '']) scroller.main(self.test_str, args) expected_call = call(self.test_str, end='\r') mock_print.assert_has_calls([expected_call for i in range(c)])
def test_postfix(self, mock_print, mock_sleep): args = scroller.parser.parse_args([ '-c', '1', '-a', 'postfix', '-s', '' ]) scroller.main(' ', args) calling_args, _ = mock_print.call_args self.assertEqual(calling_args[0], ' postfix')
def test_length_when_should_be_static(self, mock_print, mock_sleep): l = len(self.test_str) + 2 c = 2 args = scroller.parser.parse_args([ '-l', str(l), '-c', str(c), '-s', '' ]) scroller.main(self.test_str, args) expected_call = call(self.test_str, end='\n') mock_print.assert_has_calls([expected_call for i in range(c)])
def test_open(self, mock_select, mock_input, mock_write, mock_print, mock_sleep): mock_input.side_effect = ['life of brian', 'flying circus'] def gen_side_effect(): yield ([sys.stdin], [], []) while True: yield ([], [], []) mock_select.side_effect = gen_side_effect() args = scroller.parser.parse_args(['-c', '2', '-o', '-m']) scroller.main(args=args) self.assertEqual(mock_input.call_count, 2) self.assertTrue(mock_write.called) self.assertTrue(mock_sleep.called)
def test_newline(self, mock_print, mock_sleep): args = scroller.parser.parse_args(['-c', '1']) scroller.main(' ', args) _, calling_kwargs = mock_print.call_args self.assertEqual(calling_kwargs['end'], '\n')
def test_separator(self, mock_print, mock_sleep): s = '_' args = scroller.parser.parse_args(['-c', '1', '-s', s, '-r']) scroller.main(self.test_str, args) (calling_args,), _ = mock_print.call_args self.assertEqual(calling_args, s + self.test_str)
def test_reverse(self, mock_print, mock_sleep): args = scroller.parser.parse_args(['-c', '1', '-s', '', '-r']) scroller.main(self.test_str, args) (calling_args,), _ = mock_print.call_args p = scroller.permute(self.test_str, rev=True) self.assertEqual(calling_args, p)
def test_interval(self, mock_print, mock_sleep): i = 2 args = scroller.parser.parse_args(['-c', '1', '-i', str(i)]) scroller.main(self.test_str, args) mock_sleep.assert_called_with(i)
def test_length_when_should_not_be_static(self, mock_print, mock_sleep): l = len(self.test_str) args = scroller.parser.parse_args(['-l', str(l), '-c', '5']) scroller.main(self.test_str, args) self.assertNotEqual(mock_print.call_args, self.test_str)
def test_count(self, mock_print, mock_sleep): c = 5 args = scroller.parser.parse_args(['-c', str(c)]) scroller.main(self.test_str, args) self.assertEqual(mock_print.call_count, c)