release-2.0.2.rst

Overview

This file is the release notes for **pytest version 2.0.2**, a maintenance and bug fix release for the popular Python testing framework, pytest. It documents the purpose of the release, key bug fixes, improvements, and usage notes relevant to this patch update. The file provides users and developers with a concise summary of changes made since the previous version (2.0.1), highlighting enhancements in test speed, improved handling of skip/xfail expressions, and better integration of fixtures.

Pytest is a mature testing tool supporting multiple Python interpreters (CPython 2.4 through 3.2, Jython, and PyPy). This release focuses on stability, performance, and usability improvements based on community feedback and issue reports.


Detailed Explanations

Purpose and Functionality

The release notes serve primarily to:

They are not source code but a documentation artifact essential for maintaining transparency and smooth transition between versions.


Key Sections and Highlights

Installation Instructions

pip install -U pytest
# or
easy_install -U pytest

These commands upgrade or install the new pytest version.


Notable Fixes and Improvements

  1. Speedup of Test Runs (Issue 32)

    • Reduced overhead in the execution of very quick test functions.

    • Results in faster overall test suite execution times.

  2. Improved xfail and skipif Support (Issue 30)

    • Enhanced expression handling for skip/xfail decorators.

    • Syntax errors in these expressions now produce clear, informative error reports.

    • Module globals can be accessed in skip/xfail conditions, enabling dynamic test skipping based on module state.

    • Example usage:

      import pytest
      import mymodule
      
      @pytest.mark.skipif("mymodule.__version__[0] == '1'")
      def test_function():
          pass
      
    • This feature improves test run summaries by clearly stating the conditions for skipping/failing tests.

  3. Integration of setup_method with pytest_generate_tests (Issue 28)

    • The fixture method setup_method is now called for each test invocation generated dynamically by pytest_generate_tests.

    • This ensures consistent setup behavior regardless of how tests are parametrized.

  4. collectonly and Keyword Selection Compatibility (Issue 27)

    • Using --collectonly with -k keyword filtering produces a flat list of test IDs.

    • These IDs can be copied and used directly to run specific tests, improving test selection workflows.

  5. Compatibility Fixes

    • Fixes related to Python 3.2 and Windows XP support, especially for tmpdir fixtures and symlink handling.

    • Addressed encoding issues with --pdb debugging mode.

    • Reduced deprecation warnings when accessing test nodes.

    • Improved verbose test progress output for test classes.

    • Cleaner tracebacks by avoiding unittest assertion helper code.


How This File Interacts With the System


Implementation Details

Since this is a release notes document, it does not contain executable code or algorithms. However, it references important implementation improvements in pytest's core:


Usage Example

Users upgrading to pytest 2.0.2 can expect the following benefits:

pip install -U pytest

Then, tests using skip/xfail markers can be written like this:

import pytest
import mymodule

@pytest.mark.skipif("mymodule.__version__[0] == '1'")
def test_example():
    assert True

This test will be skipped dynamically based on the version of `mymodule`.


Visual Diagram

The following Mermaid **flowchart** illustrates the **key features and fixes workflow** addressed in this release note:

flowchart TD
    A[Start: pytest 2.0.1] --> B[Identify Issues]
    B --> C{Issue Type?}
    C -->|Speed| D[Speed up quick tests]
    C -->|Skip/Xfail| E[Improve skip/xfail expressions]
    C -->|Fixtures| F[Integrate setup_method with pytest_generate_tests]
    C -->|Test Collection| G[Fix collectonly with keyword selection]
    C -->|Compatibility| H[Fix Python3.2, WindowsXP tmpdir bugs]
    C -->|Other| I[Fix verbose output, deprecations, tracebacks]

    D --> J[Apply Optimizations]
    E --> K[Enhanced Expression Handling]
    F --> L[Ensure Setup Calls for Parametrized Tests]
    G --> M[Better Test Selection Output]
    H --> N[Platform Compatibility Fixes]
    I --> O[Miscellaneous Fixes]

    J & K & L & M & N & O --> P[Release pytest 2.0.2]
    P --> Q[Users Upgrade & Benefit]

Summary

The [release-2.0.2.rst](/projects/286/66986) file is a critical documentation artifact outlining the incremental improvements and bug fixes in pytest 2.0.2. It aids users in understanding enhancements related to test speed, conditional skipping/failing, fixture integration, test selection, and platform compatibility. The release notes also provide installation instructions and acknowledge contributors, ensuring transparency and community engagement.

This file acts as a bridge between developers and users, clarifying the impact of the latest fixes on testing workflows and encouraging adoption of the updated pytest version.