# file scalene/scalene_utility.py:186-211 # lines [186, 187, 190, 193, 194, 195, 196, 198, 207, 208, 209, 211] # branches [] import os import pytest import shutil import tempfile import threading import webbrowser from http.server import HTTPServer, SimpleHTTPRequestHandler from scalene.scalene_utility import show_browser # Define a simple HTTP server for testing purposes class TestHTTPServer(threading.Thread): # Prevent pytest from considering this class as a test __test__ = False def __init__(self, port): super().__init__() self.port = port self.httpd = HTTPServer(("localhost", self.port), SimpleHTTPRequestHandler) self.daemon = True def run(self): self.httpd.serve_forever() def stop(self): self.httpd.shutdown() @pytest.fixture(scope="module") def server(): port = 8000 # Use a common port for testing server = TestHTTPServer(port) server.start() yield server server.stop() @pytest.fixture(scope="module") def temp_html_file(): # Create a temporary HTML file temp_dir = tempfile.mkdtemp() # Create a new temporary directory file_path = os.path.join(temp_dir, "index.html") with open(file_path, "w") as f: f.write("