Exemplo n.º 1
0
class Test(unittest.TestCase):
    def setUp(self):
        self.os=Mock()
        self.file=Mock(write=MagicMock())
        self.sys=Mock(stdout=self.file)
        self.screen_printer = ScreenPrinter(self.os,  self.sys)
    
    def test_print_lines(self):
        lines = ['a', 'b']
        self.screen_printer.print_lines(lines)
        self.file.write.assert_has_calls([call('a\n'), call('b\n')])

    def test_clear(self):
        self.screen_printer.clear()
        self.assertTrue(self.os.wasClearCalled)
        self.os.clear.assert_called()
Exemplo n.º 2
0
    def setUp(self):
        self.mock_telnet = MockTelnet()
        self.mock_os = MockOs()
        self.mock_file = MockFile()
        self.mock_file.char = 'q'
        self.mock_time = MockTime()
        self.mock_sys = MockSys(self.mock_file)
        self.mock_termios = MockTermios()
        self.mock_fcntl = MockFcntl()

        self.beanstalkd = Beanstalkd(self.mock_telnet, '', '')
        self.stats = BeanstalkdStats(self.beanstalkd)
        self.char_reader = CharReader(self.mock_os, self.mock_sys,
                                      self.mock_termios, self.mock_fcntl)
        self.screen_printer = ScreenPrinter(self.mock_os, self.mock_sys)
        self.console = Console(Clock(self.mock_time), self.char_reader,
                               self.screen_printer, self.stats)
Exemplo n.º 3
0
 def setUp(self):
     self.os=Mock()
     self.file=Mock(write=MagicMock())
     self.sys=Mock(stdout=self.file)
     self.screen_printer = ScreenPrinter(self.os,  self.sys)