pytest-fixtures
Use when pytest fixtures, conftest files, parametrize decorators, and fixture scopes for comprehensive test setup.
What this skill does
# pytest fixtures
Master Pytest fixtures, conftest files, parametrize decorators, and fixture scopes for comprehensive test setup. This skill provides comprehensive coverage of essential concepts, patterns, and best practices for professional Pytest development.
## Overview
Pytest is a powerful tool for python development, providing robust capabilities for maintaining code quality and ensuring reliable software delivery. This skill covers the fundamental through advanced aspects of working with Pytest.
## Installation and Setup
### Basic Installation
Setting up Pytest requires proper installation and configuration in your development environment.
```bash
# Installation command specific to Pytest
# Follow official documentation for latest version
```
### Project Configuration
Create appropriate configuration files and setup for your project structure:
- Configuration file setup
- Project structure organization
- Team collaboration setup
- CI/CD integration preparation
## Core Concepts
### Fundamental Principles
Understanding the core principles of Pytest is essential for effective usage:
1. **Architecture** - How Pytest is structured and operates
2. **Configuration** - Setting up and customizing behavior
3. **Integration** - Working with other tools and frameworks
4. **Best Practices** - Industry-standard approaches
### Key Features
Pytest provides several key features that make it valuable:
- Feature 1: Core functionality
- Feature 2: Advanced capabilities
- Feature 3: Integration options
- Feature 4: Performance optimization
- Feature 5: Extensibility
### Configuration Strategy
Proper configuration ensures Pytest works optimally:
- Environment-specific setup
- Team standards enforcement
- Performance tuning
- Error handling configuration
### Advanced Usage
For complex scenarios, Pytest offers advanced capabilities:
- Custom extensions
- Advanced patterns
- Performance optimization
- Scalability considerations
## Code Examples
### Example 1: Basic Setup
```python
// Basic Pytest setup
// Demonstrates fundamental usage patterns
// Shows proper initialization and configuration
// Core setup code
function basicSetup() {
// Initialize framework
// Configure basic options
// Return configured instance
}
// Usage example
const instance = basicSetup();
```
### Example 2: Configuration
```python
// Configuration example for Pytest
// Shows how to properly configure
// Includes common options and patterns
// Configuration object
const config = {
option1: 'value1',
option2: 'value2',
advanced: {
setting1: true,
setting2: false
}
};
// Apply configuration
function applyConfig(config) {
// Validation logic
// Application logic
// Return result
}
```
### Example 3: Advanced Pattern
```python
// Advanced usage pattern
// Demonstrates sophisticated techniques
// Shows best practices in action
function advancedPattern() {
// Setup phase
// Execution phase
// Cleanup phase
}
```
### Example 4: Integration
```python
// Integration with other tools
// Shows real-world usage
// Demonstrates interoperability
function integrationExample() {
// Setup integration
// Execute workflow
// Handle results
}
```
### Example 5: Error Handling
```python
// Proper error handling approach
// Defensive programming patterns
// Graceful degradation
function withErrorHandling() {
try {
// Main logic
} catch (error) {
// Error recovery
} finally {
// Cleanup
}
}
```
### Example 6: Performance Optimization
```python
// Performance-optimized implementation
// Shows efficiency techniques
// Demonstrates best practices
function optimizedApproach() {
// Efficient implementation
// Resource management
// Performance monitoring
}
```
### Example 7: Testing
```python
// Testing approach for Pytest
// Unit test examples
// Integration test patterns
function testExample() {
// Test setup
// Execution
// Assertions
// Teardown
}
```
### Example 8: Production Usage
```python
// Production-ready implementation
// Includes monitoring and logging
// Error recovery and resilience
function productionExample() {
// Production configuration
// Monitoring setup
// Error handling
// Logging
}
```
## Best Practices
1. **Follow conventions** - Adhere to established naming and structural patterns for consistency
2. **Configure appropriately** - Set up framework configuration that matches project requirements
3. **Validate inputs** - Always validate and sanitize inputs before processing
4. **Handle errors gracefully** - Implement comprehensive error handling and recovery
5. **Document decisions** - Comment configuration choices and non-obvious implementations
6. **Test thoroughly** - Write comprehensive tests for all functionality
7. **Optimize performance** - Profile and optimize critical paths
8. **Maintain security** - Follow security best practices and guidelines
9. **Keep updated** - Regularly update framework and dependencies
10. **Monitor production** - Implement logging and monitoring for production systems
## Common Pitfalls
1. **Incorrect configuration** - Misconfiguration leads to unexpected behavior and bugs
2. **Missing error handling** - Not handling edge cases causes production issues
3. **Poor performance** - Not optimizing leads to scalability problems
4. **Inadequate testing** - Insufficient test coverage misses bugs
5. **Security vulnerabilities** - Not following security best practices exposes risks
6. **Tight coupling** - Poor architecture makes maintenance difficult
7. **Ignoring warnings** - Dismissing framework warnings leads to future problems
8. **Outdated dependencies** - Using old versions exposes security risks
9. **No monitoring** - Lack of observability makes debugging difficult
10. **Inconsistent standards** - Team inconsistency reduces code quality
## Advanced Topics
### Customization
Pytest allows extensive customization for specific needs:
- Custom plugins and extensions
- Behavior modification
- Integration adapters
- Domain-specific adaptations
### Performance Tuning
Optimize Pytest performance for production:
- Profiling and benchmarking
- Resource optimization
- Caching strategies
- Parallel execution
### CI/CD Integration
Integrate Pytest into continuous integration pipelines:
- Automated execution
- Result reporting
- Quality gates
- Deployment integration
### Troubleshooting
Common issues and their solutions:
- Configuration errors
- Integration problems
- Performance issues
- Unexpected behavior
## When to Use This Skill
- Setting up Pytest in new projects
- Configuring Pytest for specific requirements
- Migrating to Pytest from alternatives
- Optimizing Pytest performance
- Implementing advanced patterns
- Troubleshooting Pytest issues
- Integrating Pytest with CI/CD
- Training team members on Pytest
- Establishing team standards
- Maintaining existing Pytest implementations
## Additional Resources
### Documentation
- Official Pytest documentation
- Community guides and tutorials
- API reference materials
- Migration guides
### Tools and Utilities
- Development tools
- Testing utilities
- Monitoring solutions
- Helper libraries
### Community
- Online forums and communities
- Open source contributions
- Best practice repositories
- Example implementations
## Conclusion
Mastering Pytest requires understanding both fundamentals and advanced concepts. This skill provides the foundation for professional-grade usage, from initial setup through production deployment. Apply these principles consistently for best results.
## Detailed Configuration Examples
### Configuration Option 1
Comprehensive configuration example demonstrating best practices and common patterns used in production environments.
```bash
# Detailed configuration setup
# Includes all necessary options
# Optimized for production use
```
### Configuration Option 2
Alternative configuration approach for different use cases, showing flexibility anRelated in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.