{ "info": { "author": "Wim Glenn", "author_email": "hey@wimglenn.com", "bugtrack_url": null, "classifiers": [ "Framework :: Pytest", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], "description": "|pypi|_ |pyversions|_ |travis|_\n\n.. |pypi| image:: https://img.shields.io/pypi/v/pytest-raisin.svg\n.. _pypi: https://pypi.org/project/pytest-raisin\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/pytest-raisin.svg\n.. _pyversions:\n\n.. |travis| image:: https://img.shields.io/travis/wimglenn/pytest-raisin.svg?branch=master\n.. _travis: https://travis-ci.com/wimglenn/pytest-raisin\n\n\n.. image:: https://user-images.githubusercontent.com/6615374/50065259-46af2780-017b-11e9-8af3-38f340f11df1.png\n\n\npytest-raisin\n=============\n\nPlugin putting a higher-level interface to `pytest.raises `_.\nIt allows to use an exception *instance* as the expected value, which would be compared with the actual exception (if any) based upon the type and the ``args`` attribute.\n\n.. code-block:: bash\n\n # Old-skool:\n with pytest.raises(SystemExit) as cm:\n sys.exit(1)\n assert cm.value.args == (1,)\n\n # New hotness:\n with pytest.raises(SystemExit(1)):\n sys.exit(1)\n\n\nMore sophisticated comparisons can be registered for user-defined error subclasses if necessary (see `Advanced Usage`_).\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n pip install pytest-raisin\n\n\nBasic Usage\n-----------\n\nUsage in your tests looks like this\n\n.. code-block:: python\n\n >>> currant_exchange_rates = {\n ... \"sultana\": 50,\n ... \"raisins\": 100,\n ... }\n >>> with pytest.raises(KeyError(\"grape\")):\n ... currant_exchange_rates[\"grape\"]\n ...\n >>> with pytest.raises(KeyError(\"sultanas\")):\n ... currant_exchange_rates[\"prunes\"]\n ...\n AssertionError: KeyError args do not match!\n Actual: ('prunes',)\n Expected: ('sultanas',)\n\n >>> with pytest.raises(KeyError(\"Carlos Sultana\")):\n ... currant_exchange_rates[\"sultana\"]\n Failed: DID NOT RAISE KeyError('Carlos Sultana')\n\n\nThe plugin is enabled by default: ``pytest.raises`` is monkeypatched with the new functionality directly. To temporarily execute without the new stuff, use ``pytest -p no:pytest-raisin``.\n\nThe various legacy forms of ``pytest.raises`` will continue to work, falling back to the original implementation.\n\n\nAdvanced Usage\n--------------\n\nIn most use-cases, the default behaviour of considering exceptions to be equivalent if the `args` attributes have matching tuples should be satisfactory.\nHowever, some 3rd-party exception classes have additional logic inside them (e.g. Django's ``ValidationError``) and you might want to provide a more custom assertion here.\n\nPlugin users may register their own errors/callables via pytest-raisin's decorator factory:\n\n\n.. code-block:: python\n\n @pytest.register_exception_compare(MyError)\n def my_error_compare(exc_actual, exc_expected):\n ...\n\nYour comparison function will be called with the arguments ``exc_actual`` and ``exc_expected``, which will *both* be directly instances of ``MyError`` (the test will have failed earlier if the type was not an exact match). This function should inspect the instances and raise an ``AssertionError`` with useful context message should they be considered not to match. It should do nothing (i.e. return ``None``) if the exceptions should be considered equivalent.\n\n**Note:** An instance of a subclass is *not* permitted when using an exception instance as the argument to ``pytest.raises``. If you want to allow subclassing, use the original syntax of passing the type.\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/wimglenn/pytest-raisin", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pytest-raisin", "package_url": "https://pypi.org/project/pytest-raisin/", "platform": "", "project_url": "https://pypi.org/project/pytest-raisin/", "project_urls": { "Homepage": "https://github.com/wimglenn/pytest-raisin" }, "release_url": "https://pypi.org/project/pytest-raisin/0.3/", "requires_dist": [ "pytest" ], "requires_python": "", "summary": "Plugin enabling the use of exception instances with pytest.raises", "version": "0.3" }, "last_serial": 5094897, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "dc2390ed3b778faa35b02368b9ca016a", "sha256": "e0849a81f263b6b682af00e379812b05a40fcdd383ace07386c5fbbf23508b7c" }, "downloads": -1, "filename": "pytest_raisin-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "dc2390ed3b778faa35b02368b9ca016a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6320, "upload_time": "2018-12-17T03:56:31", "url": "https://files.pythonhosted.org/packages/53/ae/e46a62ac3604299467edd944fbbe16c7779b20df1883cf5584d274ccb5b3/pytest_raisin-0.1-py2.py3-none-any.whl" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "432271a0a85aa62e6ce87e70615d9c09", "sha256": "d94f2ca6e381a163097bba513396c60f812c2bccedb202a47f20566d7fe1da4b" }, "downloads": -1, "filename": "pytest_raisin-0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "432271a0a85aa62e6ce87e70615d9c09", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8134, "upload_time": "2019-02-12T01:57:33", "url": "https://files.pythonhosted.org/packages/01/d9/24180177db358bf18f44c07a579edceb1cacede66622cc65688ee8a835e2/pytest_raisin-0.2-py2.py3-none-any.whl" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "2dc41531fc989fdfccb07ef705c3dc8e", "sha256": "2d95864a580098f5a203f0330e9af6b95a5e53f6f431e3a9171d42b8c70e6599" }, "downloads": -1, "filename": "pytest_raisin-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2dc41531fc989fdfccb07ef705c3dc8e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7206, "upload_time": "2019-04-04T06:13:43", "url": "https://files.pythonhosted.org/packages/bb/2a/ce0703f1242b8ce2992e24132baedf8e1c99a8ccdd8fcbb0e81904f93931/pytest_raisin-0.3-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2dc41531fc989fdfccb07ef705c3dc8e", "sha256": "2d95864a580098f5a203f0330e9af6b95a5e53f6f431e3a9171d42b8c70e6599" }, "downloads": -1, "filename": "pytest_raisin-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2dc41531fc989fdfccb07ef705c3dc8e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7206, "upload_time": "2019-04-04T06:13:43", "url": "https://files.pythonhosted.org/packages/bb/2a/ce0703f1242b8ce2992e24132baedf8e1c99a8ccdd8fcbb0e81904f93931/pytest_raisin-0.3-py2.py3-none-any.whl" } ] }