bowser/tests/README.md
Benedikt Willi ae6fcbfab4 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
2026-01-09 13:37:21 +01:00

1.1 KiB

Bowser Test Suite

This directory contains the test suite for the Bowser browser.

Running Tests

Run all tests:

uv run pytest

Run with verbose output:

uv run pytest -v

Run specific test file:

uv run pytest tests/test_browser.py

Run with coverage:

uv run pytest --cov=src --cov-report=html

View coverage report:

open htmlcov/index.html

Test Organization

  • test_url.py - URL parsing and resolution
  • test_parser.py - HTML/CSS parsing
  • test_browser.py - Browser and tab management
  • test_cookies.py - Cookie jar functionality
  • test_layout.py - Layout engine components
  • test_render.py - Rendering primitives
  • conftest.py - Shared fixtures and configuration

Writing Tests

Tests use pytest. Example:

def test_feature():
    # Arrange
    obj = MyClass()
    
    # Act
    result = obj.method()
    
    # Assert
    assert result == expected

Use mocks for GTK components:

@patch('src.browser.browser.Gtk')
def test_with_gtk(mock_gtk):
    browser = Browser()
    # test code