示例#1
0
    def test_serves_forever(self, tcp_server, observer_cls):
        httpd = mock.MagicMock()
        tcp_server.return_value = httpd
        observer = mock.MagicMock()
        observer_cls.return_value = observer

        serve(self.site, self.director)

        self.assertTrue(httpd.serve_forever.called)
        self.assertTrue(observer.start.called)
示例#2
0
    def test_serves_forever(self, tcp_server, observer_cls):
        httpd = mock.MagicMock()
        tcp_server.return_value = httpd
        observer = mock.MagicMock()
        observer_cls.return_value = observer

        serve(self.site, self.director)

        self.assertTrue(httpd.serve_forever.called)
        self.assertTrue(observer.start.called)
示例#3
0
    def test_server_quits_on_keyboard_interrupt(self, tcp_server,
                                                observer_cls):
        httpd = mock.MagicMock()
        httpd.serve_forever.side_effect = KeyboardInterrupt
        tcp_server.return_value = httpd
        observer = mock.MagicMock()
        observer_cls.return_value = observer

        serve(self.site, self.director)

        self.assertTrue(observer.stop.called)
示例#4
0
    def test_server_quits_on_keyboard_interrupt(
            self, tcp_server, observer_cls):
        httpd = mock.MagicMock()
        httpd.serve_forever.side_effect = KeyboardInterrupt
        tcp_server.return_value = httpd
        observer = mock.MagicMock()
        observer_cls.return_value = observer

        serve(self.site, self.director)

        self.assertTrue(observer.stop.called)
示例#5
0
    def test_server_quits_on_keyboard_interrupt(
            self, tcp_server, observer_cls):
        httpd = mock.MagicMock()
        httpd.serve_forever.side_effect = KeyboardInterrupt
        tcp_server.return_value = httpd
        observer = mock.MagicMock()
        observer_cls.return_value = observer

        try:
            serve(self.site, self.director)
        except KeyboardInterrupt:
            self.fail('Server did not quit gracefully.')
        self.assertTrue(observer.stop.called)
示例#6
0
文件: watch.py 项目: iter8ve/handroll
 def run(self, args):
     site = Site.build(args)
     director = prepare_director(args, site)
     director.produce()
     serve(site, director)
示例#7
0
 def run(self, args):
     site = Site.build(args)
     director = prepare_director(args, site)
     director.produce()
     serve(site, director)