From ae6fcbfab4271291406b06867fb65cd9281967e2 Mon Sep 17 00:00:00 2001 From: Benedikt Willi Date: Fri, 9 Jan 2026 13:37:21 +0100 Subject: [PATCH] Add comprehensive test suite with pytest - Add tests for URL parsing, cookies, HTML/CSS parsing - Add tests for browser/tab management and history - Add tests for layout and rendering components - Configure pytest with coverage reporting - Add test documentation and runner commands - All 54 tests passing --- .gitignore | 1 + README.md | 31 +++ pyproject.toml | 26 +++ .../__pycache__/browser.cpython-313.pyc | Bin 6918 -> 6918 bytes .../__pycache__/chrome.cpython-313.pyc | Bin 12114 -> 12114 bytes src/browser/__pycache__/tab.cpython-313.pyc | Bin 4382 -> 4382 bytes tests/README.md | 64 ++++++ tests/conftest.py | 22 ++ tests/test_browser.py | 210 ++++++++++++++++++ tests/test_cookies.py | 41 ++++ tests/test_layout.py | 58 +++++ tests/test_parser.py | 52 +++++ tests/test_render.py | 55 +++++ tests/test_url.py | 41 ++++ 14 files changed, 601 insertions(+) create mode 100644 .gitignore create mode 100644 tests/README.md create mode 100644 tests/conftest.py create mode 100644 tests/test_browser.py create mode 100644 tests/test_cookies.py create mode 100644 tests/test_layout.py create mode 100644 tests/test_parser.py create mode 100644 tests/test_render.py create mode 100644 tests/test_url.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c18dd8d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/README.md b/README.md index 1e8a364..c2eb46c 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,37 @@ uv sync uv run bowser ``` +### Testing +Run the test suite: +```bash +# Install dev dependencies +uv sync --extra dev + +# Run all tests +uv run pytest + +# Run with verbose output +uv run pytest -v + +# Run with coverage report +uv run pytest --cov=src --cov-report=html + +# Run specific test file +uv run pytest tests/test_browser.py +``` + +### Development +```bash +# Format code +uv run black src tests + +# Lint code +uv run ruff check src tests + +# Type check +uv run mypy src +``` + ## Project Structure ``` diff --git a/pyproject.toml b/pyproject.toml index 058cf1c..db37c9a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,3 +47,29 @@ python_version = "3.11" warn_return_any = true warn_unused_configs = true disallow_untyped_defs = false + +[tool.pytest.ini_options] +testpaths = ["tests"] +python_files = ["test_*.py"] +python_classes = ["Test*"] +python_functions = ["test_*"] +addopts = [ + "-ra", + "--strict-markers", + "--strict-config", + "--showlocals", +] + +[tool.coverage.run] +source = ["src"] +omit = ["tests/*", "*/conftest.py"] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise AssertionError", + "raise NotImplementedError", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] diff --git a/src/browser/__pycache__/browser.cpython-313.pyc b/src/browser/__pycache__/browser.cpython-313.pyc index b1371b688741e8e52dd2d39788503123da11d615..345016bacc9d10ceb3d3433d72b2707595396fbe 100644 GIT binary patch delta 19 ZcmZoOYcu2e%*)Hg00bMqY~=bQ1pqgQ1`q%M delta 19 ZcmZoOYcu2e%*)Hg00h@QZ{+$T1pqi<1~dQw diff --git a/src/browser/__pycache__/chrome.cpython-313.pyc b/src/browser/__pycache__/chrome.cpython-313.pyc index 373e54f2bd6c199a2b76f47cfbc8219a62bd7863..00bccf241968e01dc7e8c2366a3f8af91a47cc3b 100644 GIT binary patch delta 19 ZcmcZ