Skip to content

Migration to Py.test testing framework #6731

@Kojoley

Description

@Kojoley

This task has been started in PR #5405, but ended without success, so I have decided to split it to multiple stages:

  1. Make pytest compatible with the current test suite
  2. Migration to pytest
    • Add new build under allow_failures with pytest
      • Appveyor
      • Travis
      • Use pytest-cov for coverage reports
    • Replace nose in all builds with pytest
  3. Post-migration
    • Rename setUp -> setup_method and other methods to pytest analogs
      • Do not inherit tests from unitest.UnitTest class
      • Remove setUp/tearDown workaround
    • Rewrite image_comparison decorator (currently it slowdowns the collection phase due to baseline images copying) or use pytest-mpl plugin (needs some improvements, see paragraph below)
    • Rewrite all assertations to pure assert
    • Get away from cleanup decorator
    • Replace knownfailif with mark.xfail
    • Replace raise nose.SkipTest(...) with xfail(...) call or mark.skipif decorator
  4. Enhancements
    • Replace setup_method and etc methods with fixtures
    • Rewrite test_delaunay.make_all_2d_testfuncs
    • Use pytest-pep8 plugin instead of test_coding_standards
    • Use pytest-mock plugin instead of mock and unittest.mock

Tests entry point (raised in #5405 (comment))

I think that running tests with simple py.test command is better than python tests.py, but there are unused tests which will run that way. Solutions:

  • A. Get them away from pytest's sight with:
    1. Remove unused tests (test_sankey, test_skew, test_ttconv, and test_usetex from lib/matplotlib/tests)
    2. Rename test_only.py (to setup_test_only.py probably)
  • B. Make filter for collection phase.
    1. Implement whitelist
    2. Implement blacklist

I have tried both ways and they work, so what to choose is up to you.

  • py.test --collect-filter=none
  • py.test --collect-filter=blacklist
  • py.test --collect-filter=whitelist

Currently --collect-filter=whitelist is default (to follow same politics as nose does currently).

Image comparison decorator

Why do we have to rewrite image_comparison decorator? Because pytest-mpl plugin in the current state ("as is") is not usable for matplotlib:

  • + supports savefig_kwargs
  • + supports tolerance
  • ‒ need to supply baseline_dir in every decorator
  • ‒ does not support image format conversion
  • ‒ need something to do with freetype_version, remove_text, and style

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy