release-2.4.2.rst
Overview
This file is the release announcement notes for **pytest version 2.4.2**, a bug-fixing update to the popular Python testing framework. It provides a summary of key bug fixes, improvements, and new APIs introduced in this patch release, aimed at improving plugin compatibility, Windows support, test discovery accuracy, and fixture behavior.
The document serves as an official communication to developers and users about what has changed, what issues have been resolved, and how to upgrade pytest safely.
Key highlights of this release include integration with the `colorama` library for improved terminal color handling on Windows, fixes to the `-k` test selection matching, better filename handling in the `tmpdir` fixture, and enhancements to plugin APIs.
Detailed Explanation
Content Type
This file is a **release notes document**, written in reStructuredText (RST), suitable for display on project websites, PyPI, or internal changelogs.
Sections & Details
1. Windows color support via colorama
Issue addressed: On Windows, pytest previously used custom ctypes hacks to manage terminal colors.
Fix: pytest 2.4.2 now requires the
coloramapackage and a newer py library version.Benefit: This makes terminal color output more stable and standard-compliant.
Issue Reference: #365
Acknowledgment: Thanks to Paul Moore for reporting.
2. Fix -k option test matching
Problem: The
-koption allows selecting tests by substring matching, but internal quirks caused incorrect matches with terms like "repr" or"attr".Change: The matching mechanism was corrected to avoid false positives.
Issue Reference: #345
3. tmpdir fixture filename length fix
Problem: When using parameterized tests,
tmpdircould create excessively long filenames causing issues on some file systems.Fix: The fixture was improved to avoid overly long filename generation.
Issue Reference: #354
4. pytest-pep8 and pytest-flakes plugin compatibility fixes
Problem: These plugins assumed test items always had function objects, which is not always true.
Fix: Collection name handling in the mark plugin was corrected.
Acknowledgment: Thanks to Andi Zeidler.
5. New node marker API
New API: Introduced
node.get_marker()andnode.add_marker()to simplify marker management.Purpose: Provides plugins a cleaner interface than directly manipulating node.keywords dictionaries.
Effect: Cleaner plugin code and better compatibility with marking conventions.
6. Removal of stdout duplication at startup
Reason: The previous duplication of standard output file descriptors was problematic and unnecessary.
Change: Removed this behavior relying instead on pytest’s standard capturing mechanisms.
7. Plugin manager enhancement
New method: pluginmanager.do_configure(config) added as a convenience method, forwarding to
config.do_configure().Benefit: Enhances plugin compatibility by providing a standardized hook.
Usage Example
Since this file is a release notes document, it is **not executable code** and does not contain functions or classes. However, users should:
Upgrade pytest using:
pip install -U pytestConsult the official documentation for the new marker API and plugin compatibility details.
Implementation Details & Algorithms
This file itself is a plain text changelog and does not implement algorithms or classes. The notes mention internal changes in pytest core, such as:
Replacement of Windows terminal color handling with
colorama.Improved string matching algorithms for the
-koption.Changes to fixture filename generation to handle parameterized test cases.
API improvements for plugin marker management.
Interactions with Other System Components
colorama package: Now a required dependency on Windows platforms for terminal color support.
pytest plugins: The new
node.get_marker()andnode.add_marker()APIs improve compatibility with plugins likepytest-pep8andpytest-flakes.Test discovery and selection: The
-koption bug fix improves test filtering accuracy, affecting how pytest identifies which tests to run.tmpdir fixture: A core pytest fixture used in tests, improved in this release to generate safer filenames.
Visual Diagram
Since this file is a **release documentation file** and does not define classes or functions, a class diagram is not applicable. Instead, a **flowchart representing the key updates and their relationships** is appropriate to illustrate the release structure.
flowchart TD
A[pytest 2.4.2 Release]
A --> B[Windows Terminal Color Fix]
B --> B1[colorama dependency added]
A --> C[-k Option Matching Fix]
C --> C1[Improved test selection accuracy]
A --> D[tmpdir Fixture Fix]
D --> D1[Shorter filenames with parametrization]
A --> E[Plugin Compatibility]
E --> E1[Fix pytest-pep8 & pytest-flakes]
E --> E2[Add node.get_marker() and node.add_marker()]
E --> E3[pluginmanager.do_configure() added]
A --> F[Stdout Duplication Removed]
F --> F1[Rely on standard capturing mechanisms]
Summary
This release notes file for pytest 2.4.2 documents important bug fixes and enhancements focusing on:
Better Windows compatibility via
colorama.More accurate test filtering with
-k.Improved fixture filename handling.
Cleaner and more compatible plugin APIs.
It is intended for pytest users and plugin developers to understand what has changed and how to upgrade. The file itself is a static changelog and does not contain executable code or classes.
For detailed usage of new APIs and features, users should consult the official pytest documentation at [http://pytest.org](http://pytest.org).