==================================
unittest2pytest
==================================
-----------------------------------------------------
Helps converting unittest test-cases to pytest
-----------------------------------------------------
:Author: Hartmut Goebel <h.goebel@crazy-compilers.com>
:Version: 0.5.dev0
:Copyright: 2015 by Hartmut Goebel
:Licence: GNU Public Licence v3 or later (GPLv3+)
:Homepage: https://github.com/pytest-dev/unittest2pytest
.. image:: https://github.com/pytest-dev/unittest2pytest/actions/workflows/test.yml/badge.svg
:target: https://github.com/pytest-dev/unittest2pytest/actions
:alt: See Build Status on GitHub Actions
`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
Note: if your tests use the context managers ``with self.assertRaises`` or
``with self.assertWarns``, they will be transformed to ``pytest.raises`` or
``pytest.warns`` appropriately, but because the semantics are different, any
use of the output value from the context managers (e.g. the ``x`` in
``with pytest.raises(ValueError) as x:``) will be wrong and will require
manual adjustment after the fact.
.. _`lib2to3 documentation`: http://docs.python.org/library/2to3.html
.. _pytest: https://pytest.org/
..
Local Variables:
mode: rst
ispell-local-dictionary: "american"
coding: utf-8
End:
Changelog
============
0.5
---
*2024-12-10*
- Convert ``self.fail()`` to ``pytest.fail()`` (`#39`_).
- Python >=3.9 is now required.
- Allow non-string keys when translating ``assertDictContainsSubset`` (`#54`_).
.. _#39: https://github.com/pytest-dev/unittest2pytest/issues/39
.. _#54: https://github.com/pytest-dev/unittest2pytest/issues/54
0.4 (2019-06-30)
----------------
* Add support for ``assertDictContainsSubset``.
* Put parenthesis around expressions if required.
* Fixed assertRaisesRegex, assertRaisesRegexp and assertWarnsRegex.
The regex was getting replaced with an undefined variable `pattern`.
* Fix assertRaisesRegex and assertRaisesRegexp with `**kwargs` and
`atom` parameters.
* Made assertRaisesRegex, assertRaisesRegexp and assertWarnsRegex use
the `match` kwarg in `pytest.raises` instead of creating a variable
with the context manager and doing an assert on `re.search`.
* Add a short developer guide.
* Remove testing on Python 3.0, 3.1, 3.2, add 3.6 and 3.7.
* Distribute package as a universal wheel.
v0.3 (2016-07-26)
------------------
* Add support for assertRaises / assertWarns context managers.
* Add support for converting lambda arguments in assertRaises into
context managers.
* Fix some incorrect transformations.
* Internal cleanup and fixes.
v0.2 (2015-10-20)
---------------------
* Add support for assertRegex/assertRegexpMatches, assertNotRegex,
assertRaisesRegex/assertRaisesRegexp, assertWarnsRegex.
* `unittest2pytest` is now a `pytest` subproject.
* Minor fixes.
v0.1 (2015-10-16)
---------------------
* Initial release
..
Local Variables:
mode: rst
ispell-local-dictionary: "american"
coding: utf-8
End:
Raw data
{
"_id": null,
"home_page": "https://github.com/pytest-dev/unittest2pytest",
"name": "unittest2pytest",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Hartmut Goebel",
"author_email": "h.goebel@crazy-compilers.com",
"download_url": "https://files.pythonhosted.org/packages/87/cd/8754c5c8b2962f419b40649ef32b15a68ea16f5efd92e39ca3425a1ae675/unittest2pytest-0.5.tar.gz",
"platform": null,
"description": "==================================\nunittest2pytest\n==================================\n\n-----------------------------------------------------\nHelps converting unittest test-cases to pytest\n-----------------------------------------------------\n\n:Author: Hartmut Goebel <h.goebel@crazy-compilers.com>\n:Version: 0.5.dev0\n:Copyright: 2015 by Hartmut Goebel\n:Licence: GNU Public Licence v3 or later (GPLv3+)\n:Homepage: https://github.com/pytest-dev/unittest2pytest\n\n\n.. image:: https://github.com/pytest-dev/unittest2pytest/actions/workflows/test.yml/badge.svg\n :target: https://github.com/pytest-dev/unittest2pytest/actions\n :alt: See Build Status on GitHub Actions\n\n`unittest2pytest` is a tool that helps rewriting Python `unittest`\ntest-cases into pytest_ test-cases.\n\nIn contrast to other similar tools, this `unittest2pytest`\n\n* handles keyword arguments,\n* handles single-line test-cases and several tests on one line,\n* uses context-handlers where appropriate.\n\nThis is done by using ``lib2to3`` and Python's mighty ``inspect``\nmodule.\n\n\n\nInstallation\n===================\n\nTo install unittest2pytest, simply run::\n\n pip install unittest2pytest\n\n\nUsage\n===================\n\nTo print a diff of changes that unittest2pytest will make against a\nparticular source file or directory::\n\n unittest2pytest source_folder\n\nTo have those changes written to the files::\n\n unittest2pytest -w source_folder\n\nTo have those changes written to another directory::\n\n unittest2pytest -w source_folder --output-dir /some/where/else\n\nBy default, this will create backup files for each file that will be\nchanged. You can add the `-n` option to not create the backups. Please\ndo not do this if you are not using a version control system.\n\nFor more options about running particular fixers, run\n``unittest2pytest --help`` or read the `lib2to3 documentation`_. This\ntool is built on top of that one.\n\n\nFixes\n===================\n\nA list of the available fixers can be found with the following::\n\n $ unittest2pytest -l\n Available transformations for the -f/--fix option:\n remove_class\n self_assert\n\n\nNote: if your tests use the context managers ``with self.assertRaises`` or\n``with self.assertWarns``, they will be transformed to ``pytest.raises`` or\n``pytest.warns`` appropriately, but because the semantics are different, any\nuse of the output value from the context managers (e.g. the ``x`` in\n``with pytest.raises(ValueError) as x:``) will be wrong and will require\nmanual adjustment after the fact.\n\n.. _`lib2to3 documentation`: http://docs.python.org/library/2to3.html\n.. _pytest: https://pytest.org/\n\n\n..\n Local Variables:\n mode: rst\n ispell-local-dictionary: \"american\"\n coding: utf-8\n End:\n\n\nChangelog\n============\n\n0.5\n---\n\n*2024-12-10*\n\n\n- Convert ``self.fail()`` to ``pytest.fail()`` (`#39`_).\n\n- Python >=3.9 is now required.\n\n- Allow non-string keys when translating ``assertDictContainsSubset`` (`#54`_).\n\n.. _#39: https://github.com/pytest-dev/unittest2pytest/issues/39\n.. _#54: https://github.com/pytest-dev/unittest2pytest/issues/54\n\n\n\n0.4 (2019-06-30)\n----------------\n\n* Add support for ``assertDictContainsSubset``.\n\n* Put parenthesis around expressions if required.\n \n* Fixed assertRaisesRegex, assertRaisesRegexp and assertWarnsRegex.\n The regex was getting replaced with an undefined variable `pattern`.\n\n* Fix assertRaisesRegex and assertRaisesRegexp with `**kwargs` and\n `atom` parameters.\n\n* Made assertRaisesRegex, assertRaisesRegexp and assertWarnsRegex use\n the `match` kwarg in `pytest.raises` instead of creating a variable\n with the context manager and doing an assert on `re.search`.\n\n \n* Add a short developer guide.\n\n* Remove testing on Python 3.0, 3.1, 3.2, add 3.6 and 3.7.\n \n* Distribute package as a universal wheel.\n\n\nv0.3 (2016-07-26)\n------------------\n\n* Add support for assertRaises / assertWarns context managers.\n\n* Add support for converting lambda arguments in assertRaises into\n context managers.\n\n* Fix some incorrect transformations.\n\n* Internal cleanup and fixes.\n\n\nv0.2 (2015-10-20)\n---------------------\n\n* Add support for assertRegex/assertRegexpMatches, assertNotRegex,\n assertRaisesRegex/assertRaisesRegexp, assertWarnsRegex.\n\n* `unittest2pytest` is now a `pytest` subproject.\n\n* Minor fixes.\n\n\nv0.1 (2015-10-16)\n---------------------\n\n* Initial release\n\n..\n Local Variables:\n mode: rst\n ispell-local-dictionary: \"american\"\n coding: utf-8\n End:\n",
"bugtrack_url": null,
"license": "GPLv3+",
"summary": "Convert unittest test-cases to pytest",
"version": "0.5",
"project_urls": {
"Homepage": "https://github.com/pytest-dev/unittest2pytest"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c834b07285db118613c72aa26374058f0a5afbfd78f71f97dafb909f827edcbd",
"md5": "00501cafd7d05dd3ad60bd82629541a7",
"sha256": "86d27a34e526a0667a5115738f45b0e108575dfb1f95643565aa9d867928411f"
},
"downloads": -1,
"filename": "unittest2pytest-0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "00501cafd7d05dd3ad60bd82629541a7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 25647,
"upload_time": "2024-12-11T00:39:33",
"upload_time_iso_8601": "2024-12-11T00:39:33.003409Z",
"url": "https://files.pythonhosted.org/packages/c8/34/b07285db118613c72aa26374058f0a5afbfd78f71f97dafb909f827edcbd/unittest2pytest-0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "87cd8754c5c8b2962f419b40649ef32b15a68ea16f5efd92e39ca3425a1ae675",
"md5": "36d63e70eb882f93b878dd73888785a2",
"sha256": "245db168f4286470ffc932b8d055cd0062ff26dfe2c8138ba8cc93672bb520f4"
},
"downloads": -1,
"filename": "unittest2pytest-0.5.tar.gz",
"has_sig": false,
"md5_digest": "36d63e70eb882f93b878dd73888785a2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 34674,
"upload_time": "2024-12-11T00:39:35",
"upload_time_iso_8601": "2024-12-11T00:39:35.322765Z",
"url": "https://files.pythonhosted.org/packages/87/cd/8754c5c8b2962f419b40649ef32b15a68ea16f5efd92e39ca3425a1ae675/unittest2pytest-0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-11 00:39:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pytest-dev",
"github_project": "unittest2pytest",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "unittest2pytest"
}