Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
*.pyc
*.sublime-project
*.sublime-workspace

# Testing
.pytest_cache/
.coverage
htmlcov/
coverage.xml
*.cover
*.py,cover
.hypothesis/

# Poetry
dist/

# Virtual environments
venv/
.venv/
env/
.env/
ENV/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# Build artifacts
build/
__pycache__/
*.egg-info/
.eggs/

# OS files
.DS_Store
Thumbs.db

# Claude settings
.claude/*
88 changes: 88 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Testing Guide for Filter Lines

This project uses Poetry for dependency management and pytest for testing.

## Setup

1. Install Poetry if you haven't already:
```bash
curl -sSL https://install.python-poetry.org | python3 -
```

2. Install dependencies:
```bash
poetry install --no-root
```

## Running Tests

You can run tests in several ways:

```bash
# Run all tests
poetry run pytest

# Run with verbose output
poetry run pytest -v

# Run specific test file
poetry run pytest tests/test_setup_validation.py

# Run tests matching a pattern
poetry run pytest -k "test_filter"

# Run only unit tests
poetry run pytest -m unit

# Run only integration tests
poetry run pytest -m integration

# Run tests excluding slow ones
poetry run pytest -m "not slow"
```

## Coverage Reports

The project is configured to generate coverage reports automatically:

```bash
# Run with coverage (default)
poetry run pytest

# View coverage in terminal
poetry run pytest --cov-report=term

# Generate HTML coverage report
poetry run pytest --cov-report=html
# Open htmlcov/index.html in your browser

# Skip coverage
poetry run pytest --no-cov
```

## Test Structure

- `tests/` - Root test directory
- `conftest.py` - Shared pytest fixtures
- `unit/` - Unit tests (fast, isolated)
- `integration/` - Integration tests
- `test_setup_validation.py` - Validation tests for the testing infrastructure

## Writing Tests

1. Place unit tests in `tests/unit/`
2. Place integration tests in `tests/integration/`
3. Use the fixtures defined in `conftest.py` for mocking Sublime Text APIs
4. Mark tests appropriately: `@pytest.mark.unit`, `@pytest.mark.integration`, `@pytest.mark.slow`

## Available Fixtures

See `tests/conftest.py` for all available fixtures:
- `mock_sublime` - Mocked sublime module
- `mock_sublime_plugin` - Mocked sublime_plugin module
- `mock_view` - Mocked Sublime Text view
- `mock_window` - Mocked Sublime Text window
- `temp_dir` - Temporary directory
- `temp_file` - Create temporary files
- `sample_text_lines` - Sample text content
- `sample_config` - Sample configuration
282 changes: 282 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
[tool.poetry]
name = "sublime-filter-lines"
version = "3.1.4"
description = "Quickly find all lines matching a string or regular expression in Sublime Text"
authors = ["David Peckham <davidpeckham@users.noreply.github.com>"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/davidpeckham/sublime-filterlines"
package-mode = false
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Plugins",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Topic :: Text Editors"
]

[tool.poetry.dependencies]
python = "^3.8"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.2"
pytest-cov = "^5.0.0"
pytest-mock = "^3.14.0"

[tool.poe.tasks]
test = "pytest"
tests = "pytest"


[tool.pytest.ini_options]
minversion = "8.0"
addopts = [
"-ra",
"--strict-markers",
"--strict-config",
"--cov=filter",
"--cov-branch",
"--cov-report=term-missing:skip-covered",
"--cov-report=html",
"--cov-report=xml",
"--cov-fail-under=80",
]
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
markers = [
"unit: marks tests as unit tests (fast, isolated)",
"integration: marks tests as integration tests (may require external dependencies)",
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
]

[tool.coverage.run]
source = ["."]
omit = [
"*/tests/*",
"*/__pycache__/*",
"*/venv/*",
"*/.venv/*",
"tests/*",
]

[tool.coverage.report]
precision = 2
show_missing = true
skip_covered = false
skip_empty = true
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]

[tool.coverage.html]
directory = "htmlcov"

[tool.coverage.xml]
output = "coverage.xml"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
3 changes: 3 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
# Run tests using Poetry
poetry run pytest "$@"
Empty file added tests/__init__.py
Empty file.
Loading