diff --git a/scripts/performance_tests.py b/scripts/performance_tests.py index c83f937..baaf1e5 100644 --- a/scripts/performance_tests.py +++ b/scripts/performance_tests.py @@ -191,7 +191,7 @@ class PerformanceTestRunner: # Local testing with Django test client if self.client is None: raise RuntimeError("Django test client not initialized") - response = self.client.get(url_path) + response = self.client.get(url_path, follow=True) end_time = time.time() duration = (end_time - start_time) * 1000 @@ -207,11 +207,19 @@ class PerformanceTestRunner: else: cache_status = "miss" # Default assumption for first generation + # Handle content length for different response types + content_length = 0 + if hasattr(response, "content"): + content_length = len(response.content) if response.content else 0 + elif hasattr(response, "streaming_content"): + # For FileResponse, we can't easily get content length without consuming the stream + content_length = 1 # Just indicate there's content + return { "test": f"{case['default']}_{case['size']}px", "duration_ms": duration, "status_code": response.status_code, - "content_length": len(response.content) if response.content else 0, + "content_length": content_length, "cache_status": cache_status, "success": response.status_code == 200, "full_url": full_url,