Python Testing, Mocking, Versioning and Tooling Updates
Testing and Development Practices
Why Mocks Fail
• The hosts discuss an insightful article by Ned Batchelder titled "Why Your Mock Doesn't Work."
• The common pitfall identified is that developers often fail to correctly mock the intended objects, leading to brittle tests.
• Key Takeaway: When integrating with third-party libraries, it is best to use a Gateway pattern to wrap only the necessary functionality, making tests easier to maintain.
Simplifying Pre-commit Hooks
• The introduction of a new Quick Start Guide for the pre-commit framework is highlighted as a major usability improvement.
• The host recommends a gradual implementation strategy: add hooks one by one rather than all at once to avoid overwhelming the team and codebase.
Tools and Libraries
Vermin: Python Compatibility Detector
• Vermin is a rules-based tool that scans code to report the minimum Python version required for specific modules or functions.
• Unlike setup.py classifiers, this tool performs static analysis on the source code itself, making it highly accurate for developers and maintainers.
Awesome Python Applications
• An updated, comprehensive list of open-source Python applications (now over 250) has been curated to serve as architectural and testing exemplars.
• Analysis reveals that two-thirds of these major applications have support for Python 3.
Microsoft Azure and Python
• Microsoft has achieved general availability for enhanced Python support on Azure, including support for native async/await.
• The ease of deploying Azure Functions—which utilize simple Git remotes to trigger Docker-based deployments—is noted as a major productivity booster for developers.
Linguistic Features
Understanding Non-local
• The hosts revisit the non-local statement, a feature often overlooked in daily coding.
"Let them use non-local and deal with the consequences." — Mahmoud Hashemi
• While useful for specific closures, it can introduce unnecessary complexity if overused; developers are encouraged to factor code cleanly instead.