{ "info": { "author": "Andreas Pelme", "author_email": "andreas@pelme.se", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Testing" ], "description": "pytest-contextfixture makes it possible to define pytest fixtures as context managers.\n\nA contextfixture works like a standard fixture, but it allows the\ndefinition to be written as a generator. This simplifies the teardown\ncode and allows for other context managers to be used within a fixture.\n\nInstallation\n============\n\npip install pytest-contextfixture\n\n\n\nUsage\n=====\n\nConsider this example, using the standard `pytest.fixture`::\n\n import pytest\n\n @pytest.fixture\n def dependency(request)\n def teardown():\n # fixture teardown code goes here\n request.addfinalizer(teardown)\n\n return 1234\n\n def test_foo(dependency):\n assert fn_under_test(dependency) == 'expected'\n\n\nWith `pytest.contextfixture`, this is equivalent::\n\n import pytest\n\n @pytest.contextfixture\n def dependency(request):\n # fixture setup code goes here\n yield 1234\n # fixture teardown code goes here\n\n def test_foo(dependency):\n assert fn_under_test(dependency) == 'expected'\n\n\nWhile this is a slightly nicer syntax, when using other context managers\nto get a dependency for a fixture, this becomes more useful::\n\n @pytest_contextfixture\n def dependency(request):\n with setup_something():\n with setup_something_else() as d:\n yield d\n\n def test_foo(dependency):\n assert fn_under_test(dependency) == 'expected'\n\ntest_foo will then run in the context of setup_something and\nsetup_something_else.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/pelme/pytest-contextfixture/", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "pytest-contextfixture", "package_url": "https://pypi.org/project/pytest-contextfixture/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pytest-contextfixture/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/pelme/pytest-contextfixture/" }, "release_url": "https://pypi.org/project/pytest-contextfixture/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Define pytest fixtures as context managers.", "version": "0.1.1" }, "last_serial": 710764, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "4d364e3eb2b7db42efeaeeec1afdcbc4", "sha256": "99cf533453fe7d68039afbce48d5a7ddaaa12117a6e0c15228a165da60f34b17" }, "downloads": -1, "filename": "pytest-contextfixture-0.1.tar.gz", "has_sig": false, "md5_digest": "4d364e3eb2b7db42efeaeeec1afdcbc4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2228, "upload_time": "2013-02-02T11:28:28", "url": "https://files.pythonhosted.org/packages/36/a0/ebf7f7f29baa293865dfca60834a5d566c511daf7c9e2d5fd83095ec3a28/pytest-contextfixture-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "c6674795b6f0bca117622cd909aa4b35", "sha256": "0b55e3875c1240c9bff5fb3f93396847692257617e7efc58845f907717278f26" }, "downloads": -1, "filename": "pytest-contextfixture-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c6674795b6f0bca117622cd909aa4b35", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3207, "upload_time": "2013-03-12T10:14:17", "url": "https://files.pythonhosted.org/packages/7b/af/ac35f60dfd9203afb0f6bd80e91fb409eb92c7bf1c6b49601928128640c4/pytest-contextfixture-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c6674795b6f0bca117622cd909aa4b35", "sha256": "0b55e3875c1240c9bff5fb3f93396847692257617e7efc58845f907717278f26" }, "downloads": -1, "filename": "pytest-contextfixture-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c6674795b6f0bca117622cd909aa4b35", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3207, "upload_time": "2013-03-12T10:14:17", "url": "https://files.pythonhosted.org/packages/7b/af/ac35f60dfd9203afb0f6bd80e91fb409eb92c7bf1c6b49601928128640c4/pytest-contextfixture-0.1.1.tar.gz" } ] }