From 51b78330a5bcb583323cfbd24d24d94f4c7db540 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Sep 2025 14:15:15 +0000 Subject: [PATCH] Update copilot instructions to use new pytest testing framework Co-authored-by: theUpsider <25013640+theUpsider@users.noreply.github.com> --- .github/copilot-instructions.md | 58 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index a076399..f99ba17 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -11,6 +11,8 @@ Always reference these instructions first and fallback to search or bash command - **`__init__.py`** - Module initialization that imports the main class - **`pyproject.toml`** - Project metadata for Comfy Registry publishing - **`README.md`** - User documentation +- **`run_tests.py`** - Test runner script using pytest framework +- **`tests/`** - Comprehensive test suite with fixtures and unit tests - **`.github/workflows/publish.yml`** - Automated publishing to Comfy Registry ### Prerequisites and Dependencies @@ -21,45 +23,33 @@ Always reference these instructions first and fallback to search or bash command ### Development Workflow - **No build process required** - This is a pure Python plugin that loads directly into ComfyUI -- **No automated tests exist** - Validation is done through manual testing and syntax checking +- **Automated testing framework** - Uses pytest with comprehensive test coverage - **No linting configuration** - Follow Python PEP 8 standards manually - Always validate Python syntax after making changes: `python3 -c "import ast; ast.parse(open('styles_csv_loader.py').read())"` - Always validate init file syntax: `python3 -c "import ast; ast.parse(open('__init__.py').read())"` ### Testing and Validation -- **CSV Parsing Testing**: Create test CSV files and validate parsing logic standalone: +- **Run the test suite**: Use the automated testing framework for comprehensive validation: ```bash - # Create test CSV in /tmp - echo 'style_name,positive_prompt,negative_prompt - cinematic,cinematic lighting professional photography,low quality blurry - vintage,"old photo sepia tone, vintage style",modern digital' > /tmp/test_styles.csv + # Run all tests + python run_tests.py - # Test parsing logic (takes <5 seconds) - python3 -c " - import os, re - def load_styles_csv(path): - with open(path, 'r', encoding='utf-8') as f: - styles = [[x.replace('\"', '').replace('\n', '') for x in re.split(',(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)', line)] for line in f.readlines()[1:]] - return {x[0]: [x[1], x[2]] for x in styles} - result = load_styles_csv('/tmp/test_styles.csv') - print(f'Loaded {len(result)} styles successfully') - " + # Run tests with coverage reporting + python run_tests.py --coverage ``` +- **Test Structure**: The test suite includes: + - Unit tests for CSV parsing logic + - Tests for various CSV formats (valid, invalid, complex) + - Integration tests for ComfyUI node functionality + - Test fixtures with sample CSV files + - **Syntax Validation**: Always run before committing changes: ```bash python3 -c "import ast; ast.parse(open('styles_csv_loader.py').read()); print('styles_csv_loader.py syntax valid')" python3 -c "import ast; ast.parse(open('__init__.py').read()); print('__init__.py syntax valid')" ``` -- **Full Integration Testing**: Requires ComfyUI environment: - 1. Install ComfyUI - 2. Copy this extension to `ComfyUI/custom_nodes/ComfyUI-Styles_CSV_Loader/` - 3. Create a test `styles.csv` in ComfyUI root directory - 4. Restart ComfyUI - 5. Verify "Load Styles CSV" node appears in loaders category - 6. Test loading different styles and verify positive/negative prompts output correctly - ### CSV File Format Requirements - Must be named `styles.csv` and located in ComfyUI root directory (where `main.py` is) - Format: `style_name,positive_prompt,negative_prompt` @@ -77,7 +67,7 @@ Always reference these instructions first and fallback to search or bash command ### Making Code Changes 1. Edit `styles_csv_loader.py` for core functionality changes 2. Run syntax validation: `python3 -c "import ast; ast.parse(open('styles_csv_loader.py').read())"` -3. Test CSV parsing with sample data (see Testing section above) +3. Run the test suite to validate changes: `python run_tests.py` 4. If changing module structure, also validate `__init__.py` ### Adding New Features @@ -90,8 +80,8 @@ Always reference these instructions first and fallback to search or bash command - `CATEGORY` for node organization ### Debugging CSV Issues -- Check that `styles.csv` exists in ComfyUI root directory -- Validate CSV format with test parsing script +- Run the test suite to identify issues: `python run_tests.py` +- Check test fixtures in `tests/fixtures/` for valid CSV examples - Common issues: - Unescaped quotes in CSV fields - Wrong number of columns @@ -116,7 +106,15 @@ Always reference these instructions first and fallback to search or bash command ├── README.md ├── __init__.py ├── pyproject.toml -└── styles_csv_loader.py +├── run_tests.py +├── styles_csv_loader.py +└── tests/ + ├── __init__.py + ├── fixtures/ + │ ├── complex_styles.csv + │ ├── invalid_styles.csv + │ └── valid_styles.csv + └── test_styles_csv_loader.py ``` ### Key Code Patterns @@ -133,7 +131,7 @@ Always reference these instructions first and fallback to search or bash command ## Validation Checklist Before committing any changes: - [ ] Run Python syntax validation on all modified .py files -- [ ] Test CSV parsing with sample data +- [ ] Run the test suite: `python run_tests.py` - [ ] Verify no new dependencies introduced - [ ] Update version in pyproject.toml if needed -- [ ] Test in actual ComfyUI environment if possible \ No newline at end of file +- [ ] Ensure all tests pass \ No newline at end of file