Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# Project : SPIDER — Universal Web Intelligence Engine7# File : tests/unit/browser/browser_testlib.py8# Module : Tests9# Repository : https://git.spboucher.ai/spider10# Project Website : Not specified11# Created : 2026-12-0412# Last Modified : 2026-12-0413#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: contact@spboucher.ai22# Development : dev@spboucher.ai23# Support : support@spboucher.ai24# Security/Admin : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License : ISC33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041"""Shared helpers of the browser engine tests (unique module name: importable from any test run)."""42from __future__ import annotations4344import importlib.util45import sys46from pathlib import Path4748PAGES = Path(__file__).resolve().parents[2] / "fixtures" / "browser_pages"49UA_SUFFIX = "SpiderTest/0.1 (+https://spboucher.ai; test)"505152def _load_server_module():53 name = "spider_browser_test_server"54 if name in sys.modules:55 return sys.modules[name]56 spec = importlib.util.spec_from_file_location(name, PAGES / "server.py")57 module = importlib.util.module_from_spec(spec)58 sys.modules[name] = module59 spec.loader.exec_module(module)60 return module616263pageserver = _load_server_module()646566def rgb(path, x: float, y: float) -> tuple[int, int, int]:67 """Colour of one pixel of an image file."""68 from PIL import Image69 with Image.open(path) as im:70 return im.convert("RGB").getpixel((int(x), int(y)))71