bowser/tests
Benedikt Willi 283dae295c Implement HTTP redirect following
- Support for 301, 302, 303, 307, 308 redirects
- Automatic Location header following
- Relative URL resolution for redirects
- Max redirect limit (default 10) to prevent infinite loops
- 303 (See Other) automatically changes method to GET
- 4 new unit tests for redirect functionality
- All 73 tests passing
2026-01-09 14:11:46 +01:00
..
__init__.py Initial bowser project scaffold 2026-01-09 12:20:46 +01:00
conftest.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
README.md Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_browser.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_cookies.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_frame.py Implement HTTP redirect following 2026-01-09 14:11:46 +01:00
test_html_parsing.py Implement HTTP redirect following 2026-01-09 14:11:46 +01:00
test_http.py Implement HTTP redirect following 2026-01-09 14:11:46 +01:00
test_layout.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_parser.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_render.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_url.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00

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