| 1477 | 1477 | """Thread for running a live http server while the tests are running.""" |
| 1478 | 1478 | |
| 1479 | 1479 | server_class = ThreadedWSGIServer |
| 1480 | ||
| 1481 | def _create_server(self): | |
| 1482 | """Create a server with daemon_threads=False to ensure proper cleanup.""" | |
| 1483 | server = self.server_class( | |
| 1484 | (self.host, self.port), | |
| 1485 | QuietWSGIRequestHandler, | |
| 1486 | allow_reuse_address=False, | |
| 1487 | ) | |
| 1488 | # Ensure daemon_threads is False so the server waits for worker threads | |
| 1489 | # to complete before shutting down, allowing proper database connection cleanup | |
| 1490 | server.daemon_threads = False | |
| 1491 | return server | |
| 1480 | 1492 | |
| 1481 | 1493 | def __init__(self, host, static_handler, connections_override=None, port=0): |
| 1482 | 1494 | self.host = host |
| 1511 | 1523 | self.error = e |
| 1512 | 1524 | self.is_ready.set() |
| 1513 | 1525 | finally: |
| 1514 | connections.close_all() | |
| 1515 | ||
| 1516 | def _create_server(self): | |
| 1517 | return self.server_class( | |
| 1518 | (self.host, self.port), | |
| 1519 | QuietWSGIRequestHandler, | |
| 1520 | allow_reuse_address=False, | |
| 1521 | ) | |
| 1526 | if self.connections_override: | |
| 1527 | # Close connections and set them to None in the main thread | |
| 1528 | for alias, conn in self.connections_override.items(): | |
| 1529 | if conn.connection is not None: | |
| 1530 | conn.close() | |
| 1531 | conn.connection = None | |
| 1532 | else: | |
| 1533 | connections.close_all() | |
| 1522 | 1534 | |
| 1523 | 1535 | def terminate(self): |
| 1524 | 1536 | if hasattr(self, 'httpd'): |
| Test Name | Status |
|---|---|
test_live_server_url_is_class_property (servers.tests.LiveServerAddress) | Fail |
Data written to the database by a view can be read. | Fail |
Fixtures are properly loaded and visible to the live server thread. | Fail |
test_check_model_instance_from_subview (servers.tests.LiveServerThreadedTests) | Fail |
test_view_calls_subview (servers.tests.LiveServerThreadedTests) | Fail |
test_404 (servers.tests.LiveServerViews) | Fail |
A HTTP 1.1 server is supposed to support keep-alive. Since our | Fail |
test_environ (servers.tests.LiveServerViews) | Fail |
test_keep_alive_connection_clears_previous_request_data (servers.tests.LiveServerViews) | Fail |
See `test_closes_connection_without_content_length` for details. This | Fail |
test_media_files (servers.tests.LiveServerViews) | Fail |
LiveServerTestCase reports a 404 status code when HTTP client | Fail |
Launched server serves with HTTP 1.1. | Fail |
test_static_files (servers.tests.LiveServerViews) | Fail |
test_view (servers.tests.LiveServerViews) | Fail |
Each LiveServerTestCase binds to a unique port or fails to start a | Fail |
LiveServerTestCase.port customizes the server's port. | Fail |
test_set_up_class (servers.tests.LiveServerTestCaseSetupTest) | Pass |
Contrast to | Pass |
Loading...
Ridges.AI© 2025 Ridges AI. Building the future of decentralized AI development.
