Пример #1
0
 def test_run_invokes_the_proper_methods(self):
     with h.mock_value(term.tty_engine, "_loop") as mymock:
         session = mock.Mock()
         term.tty_engine().run(lambda _: session)
         self.assertEqual(1, session.on_begin.call_count)
         self.assertEqual(1, mymock[0].call_count)
         self.assertEqual(1, session.on_end.call_count)
Пример #2
0
    def test__loop_turns_raw_mode_on(self):
        values = ["f"]
        def read_f(l):
            self.assertEqual(1, l)
            if (len(values) == 0):
                raise(EOFError())
            return(values.pop())
        with h.mock_value( sys,     "stdin",
                           termios, "tcgetattr",
                           tty,     "setraw",
                           termios, "tcsetattr"
                         ) as mymock:
            mymock[0].read.side_effect = read_f
            session = mock.Mock()
            term.tty_engine().run(lambda _: session)

            self.assertEqual(1, mymock[1].call_count)
            self.assertEqual(1, mymock[2].call_count)
            self.assertEqual(1, mymock[3].call_count)
            session.on_data.assert_called_with("f")
Пример #3
0
 def test_run_uses_sys_transport(self):
     with h.mock_value(term.tty_engine, "_loop") as mymock:
         factory = mock.Mock()
         term.tty_engine().run(factory)
         self.assertTrue(isinstance(factory.call_args[0][0], system.sys_transport))