Skip to main content

Convert unittest test-cases to pytest

Project description

Author:

Hartmut Goebel <h.goebel@crazy-compilers.com>

Version:
Version 0.2
Licence:

GNU Public Licence v3 or later (GPLv3+)

Homepage:

https://github.com/pytest-dev/unittest2pytest

https://secure.travis-ci.org/pytest-dev/unittest2pytest.png?branch=master

unittest2pytest is a tool that helps rewriting Python unittest test-cases into pytest test-cases.

In contrast to other similar tools, this unittest2pytest

  • handles keyword arguments,

  • handles single-line test-cases and several tests on one line,

  • uses context-handlers where appropriate.

This is done by using lib2to3 and Python’s mighty inspect module.

Installation

To install unittest2pytest, simply run:

pip install unittest2pytest

Usage

To print a diff of changes that unittest2pytest will make against a particular source file or directory:

unittest2pytest source_folder

To have those changes written to the files:

unittest2pytest -w source_folder

To have those changes written to another directory:

unittest2pytest -w source_folder --output-dir /some/where/else

By default, this will create backup files for each file that will be changed. You can add the -n option to not create the backups. Please do not do this if you are not using a version control system.

For more options about running particular fixers, run unittest2pytest --help or read the lib2to3 documentation. This tool is built on top of that one.

Fixes

A list of the available fixers can be found with the following:

$ unittest2pytest -l
Available transformations for the -f/--fix option:
remove_class
self_assert

Changelog

v0.2 (2015-10-20)

  • Add support assertRegex/assertRegexpMatches, assertNotRegex assertRaisesRegex/assertRaisesRegexp assertWarnsRegex.

  • unittest2pytest is now a pytest subproject.

  • Minor fixes.

v0.1 (2015-10-16)

  • Initial release

Project details


Download files

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

Source Distribution

unittest2pytest-0.2.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unittest2pytest-0.2-py2.py3-none-any.whl (13.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file unittest2pytest-0.2.tar.gz.

File metadata

  • Download URL: unittest2pytest-0.2.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for unittest2pytest-0.2.tar.gz
Algorithm Hash digest
SHA256 ba0f0d12b9f7078f95676e16d8efee75be84ed4032d2d33a2c2274232cc2543e
MD5 7553fef6d3ad31954780468b014f617e
BLAKE2b-256 30feabf05f49016796586d47a721e468f71fb5f97ea648648c3d49fe723ef0a3

See more details on using hashes here.

File details

Details for the file unittest2pytest-0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for unittest2pytest-0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c3203431217eb8806b485b293de9fe21de40f4fa52c8314cd7f11151468f1652
MD5 7ede76b80d7d185ad8a7114c9fa9bf57
BLAKE2b-256 f1abaa460ca1a8fe869a9a67358436b9e9397d48633ceaa9f406d2f0f3fee219

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page