@@ -23,8 +23,16 @@ pytest tests/test_proxy.py # Run specific test file
2323pytest -v # Verbose output
2424pytest --cov=proxybroker --cov-report=term-missing # Coverage analysis
2525pytest tests/test_core_functionality.py::TestBrokerCore -v # Run specific test class
26+ pytest -xvs tests/test_cli.py::TestCLI::test_cli_help # Run single test with output
27+ pytest --tb=short # Short traceback for debugging
2628```
2729
30+ ** Test Suite Status** (as of latest fixes):
31+ - ✅ Working: ` test_proxy.py ` , ` test_negotiators.py ` , ` test_resolver.py ` , ` test_utils.py ` , ` test_cli.py `
32+ - ✅ Core functionality: ` test_core_functionality.py ` (30/30 tests pass)
33+ - ⚠️ Need fixes: ` test_checker.py ` , ` test_server.py ` , ` test_api.py ` , ` test_integration.py `
34+ - Note: Many test failures are due to outdated mock implementations, not actual bugs
35+
2836### Linting and Code Quality
2937``` bash
3038flake8 proxybroker/ --max-line-length=127 --exclude=__pycache__ # Check code style
@@ -84,12 +92,13 @@ Server chooses protocols deterministically with priority order:
8492- ** HTTPS** : ` HTTPS ` > ` SOCKS5 ` > ` SOCKS4 `
8593- Uses ` _prefer_connect ` flag to prioritize CONNECT method when available
8694
87- ### Known Critical Issues (See BUG_REPORT.md)
95+ ### Recently Fixed Critical Issues (Previously in BUG_REPORT.md)
8896
89- 1 . ** Heap Corruption Risk** : ` ProxyPool.remove() ` breaks heap invariant by direct list removal
90- 2 . ** Deadlock Potential** : ` ProxyPool._import() ` infinite loop without proper bounds
91- 3 . ** Race Conditions** : Some usage of deprecated asyncio patterns remains
92- 4 . ** Resource Leaks** : Signal handlers and connections may not be properly cleaned up
97+ 1 . ✅ ** Fixed Heap Corruption** : ` ProxyPool.remove() ` now uses heap-safe removal
98+ 2 . ✅ ** Fixed Deadlock** : ` ProxyPool._import() ` has timeout and retry limits
99+ 3 . ✅ ** Fixed Async Patterns** : Replaced ` asyncio.ensure_future() ` with ` asyncio.create_task() `
100+ 4 . ✅ ** Fixed Priority Bug** : Now correctly uses ` proxy.avg_resp_time ` instead of ` proxy.priority `
101+ 5 . ✅ ** Fixed Protocol Selection** : Deterministic selection with clear priority order
93102
94103## Configuration and Environment
95104
@@ -109,7 +118,7 @@ Server chooses protocols deterministically with priority order:
109118- ** Entry Points** : Both ` py2exe_entrypoint.py ` (PyInstaller) and Poetry script
110119- ** Package Managers** : Poetry (preferred) + setuptools (legacy compatibility)
111120- ** GeoIP Database** : Embedded MaxMind GeoLite2 in ` proxybroker/data/ `
112- - ** CLI Architecture** : Click -based with subcommands (find/grab/serve)
121+ - ** CLI Architecture** : argparse -based with subcommands (find/grab/serve) - NOT Click!
113122- ** Test Structure** : Core tests (working) + comprehensive tests (may need fixes)
114123
115124## Development Guidelines
@@ -163,6 +172,19 @@ proxybroker grab --countries US --limit 10 --outfile ./proxies.txt
163172proxybroker serve --host 127.0.0.1 --port 8888 --types HTTP HTTPS --lvl High --min-queue 5
164173```
165174
175+ ### Quick Testing Commands
176+ ``` bash
177+ # Find 5 HTTP proxies quickly
178+ proxybroker find --types HTTP --limit 5
179+
180+ # Test with specific country
181+ proxybroker find --countries US --types HTTP --limit 3
182+
183+ # Run server and test with curl
184+ proxybroker serve --host 127.0.0.1 --port 8888 --types HTTP --limit 10 &
185+ curl -x http://127.0.0.1:8888 http://httpbin.org/ip
186+ ```
187+
166188## Code Quality Maintenance
167189
168190### Before Making Changes
@@ -180,4 +202,22 @@ proxybroker serve --host 127.0.0.1 --port 8888 --types HTTP HTTPS --lvl High --m
180202- Verify heap integrity after ProxyPool modifications
181203- Test async patterns with proper event loop setup
182204- Validate protocol compatibility with multiple proxy types
183- - Check resource cleanup under exception conditions
205+ - Check resource cleanup under exception conditions
206+
207+ ## Common Issues and Solutions
208+
209+ ### Test Failures
210+ - Many tests fail due to trying to make real network connections
211+ - Mock implementations often don't match current API
212+ - CLI tests expect Click but implementation uses argparse
213+ - Use ` --help ` flag in tests to avoid network calls
214+
215+ ### AsyncIO Warnings
216+ - "coroutine was never awaited" - check for missing ` await ` or ` asyncio.create_task() `
217+ - Event loop issues - ensure proper loop handling for Python 3.10+
218+ - Use ` asyncio.run() ` for main entry points, not ` loop.run_until_complete() `
219+
220+ ### Import-Time Issues
221+ - Some components try to get event loop at import time
222+ - Use ` asyncio.get_running_loop() ` with try/except for compatibility
223+ - Lazy initialization patterns help avoid import-time errors
0 commit comments