Python Testing, Async Requests, and Tooling Updates

·27m 41s
Shared point

PyTest 4.4.0 Release

Brian discusses the latest updates to PyTest version 4.4.0, highlighting several features useful for developers improving their testing workflows:

Test paths: A configuration setting that allows you to specify exactly where PyTest should look for tests, reducing overhead on large projects.
Subtests plugin: A new capability that allows tests to continue even after a single subtest failure, and a new subtests fixture that works outside of unittest.
Async warnings: PyTest will now issue warnings if tests marked as async are not executed due to missing plugins like pytest-asyncio or pytest-trio.

Async Requests and API Mocking

Michael reviews options for working with async/await syntax when making web requests, covering both current workarounds and future directions:

request-async: A library that provides an async-friendly interface for the popular requests package without requiring a total rewrite of existing code.
Future-proofing: Discussion on the eventual development of request3, which will natively support async operations, though this is likely a long-term project.
API Mocking: Tips on using local Flask or Starlette apps as mocks to simulate server behavior during tests, avoiding real network calls.

Community News: NPM and PyPI as a Service

The hosts discuss the complexities of running package repositories as a service, specifically referencing the PyPA ecosystem:

Financial Hurdles: Running a service like PyPI is expensive, and turning it into a commercial "as-a-service" product could threaten the Python Software Foundation's nonprofit status and donor support.
Marketplace and Alternatives: Mention of the DigitalOcean marketplace for one-click app deployment and the potential gap for internal package hosting solutions.

Jupyter Notebooks and Tooling

A deep dive into working with Jupyter notebooks in the cloud and educational resources:

Cloud Platforms: Discussion of services like Binder, Google Colab, Azure Notebooks, and Datalore for running interactive code without local installation.
Tutorials: Recommendation of DataQuest tutorials for both beginners and advanced users looking to master Jupyter magics and data science workflows.

Python Programming Patterns: Sentinel Values

"Instead of setting a value to none, you can set it to object... it's like the perfect sentinel value."

Michael and Brian explore the pattern of using plain object() as a unique sentinel value, which avoids the common pitfalls associated with using None as a default when None might be a valid input in the data set.

Developer Productivity Tools

PyTest-neo: A fun plugin that visualizes test execution in the terminal in a unique, descending layout.
Ace Jump: A powerful productivity tool for PyCharm or IntelliJ that allows developers to quickly jump to any string or code location using keyboard shortcuts.

Topics

Chapters

7 chapters
Python Bytes
AI chat — answers grounded in episodes