Ejemplo n.º 1
0
 def test_rotates_a_hundred_ports(self):
     app = self.get_app()
     RetriesExceeded = streamlit.server.Server.RetriesExceeded
     with pytest.raises(RetriesExceeded) as pytest_wrapped_e:
         start_listening(app)
         self.assertEqual(pytest_wrapped_e.type, SystemExit)
         self.assertEqual(pytest_wrapped_e.value.code, errno.EADDRINUSE)
         self.assertEqual(app.listen.call_count, MAX_PORT_SEARCH_RETRIES)
Ejemplo n.º 2
0
    def test_rotates_a_hundred_ports(self):
        app = self.get_app()
        with pytest.raises(SystemExit) as pytest_wrapped_e:
            start_listening(app)

            assert pytest_wrapped_e.type == SystemExit
            assert pytest_wrapped_e.value.code == errno.EADDRINUSE

            assert app.listen.call_count == MAX_PORT_SEARCH_RETRIES
Ejemplo n.º 3
0
    def test_rotates_a_hundred_ports(self):
        app = mock.MagicMock()

        RetriesExceeded = streamlit.server.Server.RetriesExceeded
        with pytest.raises(RetriesExceeded) as pytest_wrapped_e:
            with patch.object(
                tornado.httpserver, "HTTPServer", return_value=self.get_httpserver()
            ) as mock_server:
                start_listening(app)
                self.assertEqual(pytest_wrapped_e.type, SystemExit)
                self.assertEqual(pytest_wrapped_e.value.code, errno.EADDRINUSE)
                self.assertEqual(mock_server.listen.call_count, MAX_PORT_SEARCH_RETRIES)
Ejemplo n.º 4
0
    def test_rotates_one_port(self, patched_server_port_is_manually_set,
                              patched__set_option):
        app = self.get_app()

        patched_server_port_is_manually_set.return_value = False
        with pytest.raises(RetriesExceeded) as pytest_wrapped_e:
            start_listening(app)

            PortRotateOneTest.which_port.assert_called_with(8502)

            patched__set_option.assert_called_with(
                "server.port", 8501, config.ConfigOption.STREAMLIT_DEFINITION)
Ejemplo n.º 5
0
    def test_rotates_one_port(
        self, patched_server_port_is_manually_set, patched__set_option
    ):
        app = mock.MagicMock()

        patched_server_port_is_manually_set.return_value = False
        with pytest.raises(RetriesExceeded) as pytest_wrapped_e:
            with patch.object(
                tornado.httpserver, "HTTPServer", return_value=self.get_httpserver()
            ) as mock_server:
                start_listening(app)

                PortRotateOneTest.which_port.assert_called_with(8502)

                patched__set_option.assert_called_with(
                    "server.port", 8501, config.ConfigOption.STREAMLIT_DEFINITION
                )