Skip to main content

pytest plugin and bowler codemod to help migrate tests to Python 3

Project description

pytest-mark-no-py3

This package provides a pytest plugin and a Bowler codemod to help migrate tests to Python 3.

Any tests marked with @pytest.mark.no_py3 will be expected to fail when running on Python 3 and will fail the test if they pass unexpectedly.

Usage

Adding @pytest.mark.no_py3

  1. Install this package in your test dependencies.

  2. Run your tests on Python 3, savings the results with pytest's --result-log option, e.g.:

    tox -e py37 -- --result-log=test-results.txt
    
  3. Install this package with the bowler extras in a Python 3 virtualenv:

    pip install pytest_mark_no_py3[bowler]
    
  4. Apply the marker to all of the tests that failed on Python 3, running from the same directory that you ran the tests from:

    python -m pytest_mark_no_py3.add --result-log=path/to/result-log.txt path/to/your/tests
    

    If you're feeling confident, you can also use the --no-interactive option to apply the codemod without prompting to accept changes.

Removing @pytest.mark.no_py3

  1. Fix some code so that tests start passing on Python 3, violating the xfail.

  2. Run your tests on Python 3, savings the results with pytest's --result-log option, e.g.:

    tox -e py37 -- --result-log=test-results.txt
    

    Warning: The only failing tests should be the tests that you fixed and want the marker removed from!

  3. Install this package with the bowler extras in a Python 3 virtualenv:

    pip install pytest_mark_no_py3[bowler]
    
  4. Remove the marker from all of the tests that "failed" (i.e. were expected to fail but actually passed) on Python 3, running from the same directory that you ran the tests from:

    python -m pytest_mark_no_py3.remove --result-log=path/to/result-log.txt path/to/your/tests
    

    If you're feeling confident, you can also use the --no-interactive option to apply the codemod without prompting to accept changes.

Running tests

Run tox.

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pytest-mark-no-py3, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size pytest_mark_no_py3-0.1.0-py2.py3-none-any.whl (6.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size pytest-mark-no-py3-0.1.0.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page