A comprehensive skill for mastering Python testing with pytest. This skill covers everything from basic test structure to advanced patterns including fixtures, parametrization, mocking, test organization, coverage analysis, and CI/CD integration.
Works with
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionpytest-patternsExecute the skills CLI command in your project's root directory to begin installation:
Fetches pytest-patterns from manutej/luxor-claude-marketplace and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate pytest-patterns. Access via /pytest-patterns in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
2
total installs
2
this week
49
GitHub stars
0
upvotes
Run in your terminal
2
installs
2
this week
49
stars
A comprehensive skill for mastering Python testing with pytest. This skill covers everything from basic test structure to advanced patterns including fixtures, parametrization, mocking, test organization, coverage analysis, and CI/CD integration.
Use this skill when:
pytest is a mature, full-featured Python testing framework that makes it easy to write simple tests, yet scales to support complex functional testing. It provides:
assert statements instead of special assertion methods# unittest (traditional)
import unittest
class TestMath(unittest.TestCase):
def test_addition(self):
self.assertEqual(2 + 2, 4)
# pytest (simpler)
def test_addition():
assert 2 + 2 == 4
pytest automatically discovers tests by following these conventions:
test_*.py or *_test.pytest_Test (no __init__ method)test_ inside Test classesFixtures provide a fixed baseline for tests to run reliably and repeatably. They handle setup, provide test data, and perform cleanup.
import pytest
@pytest.fixture
def sample_data():
"""Provides sample data for testing."""
return {"name": "Alice", "age": 30}
def test_data_access(sample_data):
assert sample_data["name"] == "Alice"
assert sample_data["age"] == 30
Fixtures can have different scopes controlling how often they're created:
@pytest.fixture(scope="session")
def database_connection():
"""Database connection created once for entire test session."""
conn = create_db_connection()
yield conn
conn.close() # Cleanup after all tests
@pytest.fixture(scope="module")
def api_client():
"""API client created once per test module."""
client = APIClient()
client.authenticate()
yield client
client.logout()
@pytest.fixture # scope="function" is default
def temp_file():
"""Temporary file created for each test."""
import tempfile
f = tempfile.NamedTemporaryFile(mode='w', delete=False)
yield f.name
os.unlink(f.name)
Fixtures can depend on other fixtures, creating a dependency graph:
@pytest.fixture
def database():
db = Database()
db.connect()
yield db
db.disconnect()
@pytest.fixture
def user_repository(database):
"""Depends on database fixture."""
return UserRepository(database)
@pytest.fixture
def sample_user(user_repository):
"""Depends on user_repository, which depends on database."""
user = user_repository.create(name="Test User")
yield user
user_repository.delete(user.id)
def test_user_operations(sample_user):
"""Uses sample_user fixture (which uses user_repository and database)."""
assert sample_user.name == "Test User"
Fixtures that run automatically without being explicitly requested:
@pytest.fixture(autouse=True)
def reset_database():
"""Runs before every test automatically."""
clear_database()
seed_test_data()
@pytest.fixture(autouse=True, scope="session")
def configure_logging():
"""Configure logging once for entire test session."""
import logging
logging.basicConfig(level=logging.DEBUG)
Fixtures that return functions for creating test data:
@pytest.fixture
def make_user():
"""Factory fixture for creating users."""
users = []
def _make_user(name, email=None):
user = User(name=name, email=email or f"{name}@example.com")
users.append(user)
return user
yield _make_user
# Cleanup all created users
for user in users:
user.delete()
def test_multiple_users(make_user):
user1 = make_user("Alice")
user2 = make_user("Bob", email="[email protected]")
assert user1.name == "Alice"
assert user2.email == "[email protected]"
Run the same test with different inputs:
import pytest
@pytest.mark.parametrize("input_value,expected", [
(2, 4),
(3, 9),
(4, 16),
(5, 25),
])
def test_square(input_value, expected):
assert input_value ** 2 == expected
@pytest.mark.parametrize("x", [0Implementation Guide
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Steps
- 1Install skill using provided installation command
- 2Test with simple use case relevant to your work
- 3Evaluate output quality and relevance
- 4Iterate on prompts to improve results
- 5Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Related Skills
golang-backend-development
4manutej/luxor-claude-marketplace
Backendsame repotailwind-css-patterns
20giuseppe-trisciuoglio/developer-kit
Frontendtag: patternsdrizzle-orm-patterns
7giuseppe-trisciuoglio/developer-kit
Productivitytag: patternspython-design-patterns
6wshobson/agents
Frontendtag: patternsmicroservices-patterns
5wshobson/agents
Productivitytag: patternsunity-ecs-patterns
5wshobson/agents
Productivitytag: patternsReviews
4.8★★★★★65 reviews- SShikha Mishra★★★★★Dec 24, 2024
pytest-patterns has been reliable in day-to-day use. Documentation quality is above average for community skills.
- CCamila Bansal★★★★★Dec 16, 2024
Solid pick for teams standardizing on skills: pytest-patterns is focused, and the summary matches what you get after install.
- LLi Sethi★★★★★Dec 16, 2024
pytest-patterns reduced setup friction for our internal harness; good balance of opinion and flexibility.
- LLi Ghosh★★★★★Dec 8, 2024
pytest-patterns fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- LLi Reddy★★★★★Nov 27, 2024
We added pytest-patterns from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- RRahul Santra★★★★★Nov 15, 2024
pytest-patterns reduced setup friction for our internal harness; good balance of opinion and flexibility.
- LLi Gill★★★★★Nov 7, 2024
I recommend pytest-patterns for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- MMei Iyer★★★★★Nov 7, 2024
pytest-patterns has been reliable in day-to-day use. Documentation quality is above average for community skills.
- LLi Rao★★★★★Oct 26, 2024
Keeps context tight: pytest-patterns is the kind of skill you can hand to a new teammate without a long onboarding doc.
- MMei Srinivasan★★★★★Oct 26, 2024
pytest-patterns fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
showing 1-10 of 65
1 / 7Discussion
Comments — not star reviews- No comments yet — start the thread.