# Install development dependencies (includes pytest + pytest-cov)
uv pip install -e ".[dev]"
# Run all tests
uv run pytest tests/
# Run a specific test file
uv run pytest tests/test_pylumo.pyNote: This project uses uv for dependency management. Always prefix commands with uv run to ensure dependencies are available.
Comprehensive automated tests covering all core functionality without requiring credentials or network access.
Total: 32 tests across 9 categories
- ✅ PGP public key loading
- ✅ AES-256 key generation
- ✅ Encryption roundtrip verification
- ✅ PGP request key encryption
- ✅ Payload structure validation
- ✅ Tools configuration
- ✅ Targets configuration
- ✅ Turn structure
- ✅ Conversation history inclusion
- ✅ UUID request ID format
- ✅ Token data event parsing
- ✅ Multiple target handling
- ✅ Invalid JSON line resilience
- ✅ Integrity verification failure stops processing and returns explicit error
- ✅ Integrity verification failure can raise for library-mode consumers
- ✅ Text file formatting
- ✅ Binary file base64 encoding
- ✅ Image file handling
- ✅ Missing file error handling
- ✅ Empty initialization
- ✅ Clear history
- ✅ Max turns limit
- ✅ Initial state
- ✅ Authentication flow (mocked)
- ✅ Logout functionality
- ✅ Session state transitions
- ✅ TLS pin regression check for
account.proton.me(skipped if proton client not installed)
- ✅ Default None state
- ✅ File parameter handling
- ✅ Missing Proton API graceful failure
- ✅ Session save without active session
- ✅ Session load without Proton API
uv run pytest tests/# Run only encryption tests
uv run pytest tests/test_pylumo.py -k TestPyLumoEncryption
# Run only file upload tests
uv run pytest tests/test_pylumo.py -k TestPyLumoFileUploaduv run pytest tests/test_pylumo.py -k test_pgp_key_loadeduv run pytest tests/ -vtest_aes_key_generation ... ok
test_encrypt_decrypt_roundtrip ... ok
test_pgp_key_loaded ... ok
[... 29 more tests ...]
----------------------------------------------------------------------
Ran 32 tests in 0.047s
OK
================================================================================
TEST SUMMARY
================================================================================
Tests run: 32
Successes: 32
Failures: 0
Errors: 0
================================================================================
You may see CryptographyDeprecationWarning messages from pgpy/cryptography on newer Python versions. These are warnings (not test failures) and are emitted by upstream dependencies.
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Run tests
run: uv run pytest tests/import unittest
from pylumo import pyLumo
class TestNewFeature(unittest.TestCase):
"""Test description."""
def setUp(self):
"""Set up test client."""
self.client = pyLumo(quiet_mode=True)
def test_feature_works(self):
"""Test that feature works correctly."""
# Arrange
expected = "expected_value"
# Act
result = self.client.some_method()
# Assert
self.assertEqual(result, expected)- Use descriptive names:
test_encrypt_decrypt_roundtripnottest1 - One assertion per test: Keep tests focused
- Use setUp/tearDown: Clean up resources
- Mock external dependencies: Don't make real API calls in unit tests
- Test edge cases: Empty strings, None values, invalid input
- Document expected behavior: Use docstrings
# Ensure you're in the correct directory
cd /path/to/pylumo
# Check that uv is installed
uv --version
# Sync dependencies
uv sync- Check dependencies:
uv sync - Verify Python version:
python3 --version(must be 3.12+) - Run with verbose:
uv run pytest tests/ -v - Check for file conflicts: Ensure no stale
.pycfiles - Always use uv run: Don't run Python directly without
uv run
# Add print statements
def test_something(self):
result = self.client.method()
print(f"Debug: result = {result}") # Will show in test output
self.assertEqual(result, expected)
# Use pdb debugger
import pdb; pdb.set_trace() # BreakpointTo measure test coverage:
# Ensure dev dependencies are installed (includes pytest-cov)
uv pip install -e ".[dev]"
# Run tests with coverage
uv run pytest tests/ --cov=pylumo
# Generate an HTML report
uv run pytest tests/ --cov=pylumo --cov-report=html
open htmlcov/index.htmlWhen adding new features:
- Write tests first (TDD approach)
- Ensure all tests pass
- Maintain or improve coverage
- Update this documentation
- Run
python3 -m pyflakes test_pylumo.pyto check code quality
Last Updated: November 2025
Test Suite Version: 1.0
Total Tests: 32
Environment: uv (Python 3.12+)