コード例 #1
0
ファイル: test.py プロジェクト: hthuong09/scroller
 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)])
コード例 #2
0
 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')
コード例 #3
0
ファイル: test.py プロジェクト: kbrgl/scroller
 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)])
コード例 #4
0
    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)
コード例 #5
0
 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')
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
0
 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)
コード例 #9
0
 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)
コード例 #10
0
 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)