{ "info": { "author": "Asterio Gonzalez", "author_email": "asterio.gonzalez@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Operating System :: OS Independent", "Topic :: Software Development :: Testing" ], "description": "# pytest-study\nA pytest plugin for organizing long run tests (named *studies*) without interfering the regular tests\n\n## Abstract\n\nIn situations where we are developing an application or library that will be use to create long computation reports or results, we want to execute the long process only when all the project tests are passed.\n\n`pytest` provide a great support for creating test suits, parallel execution, reports, command line, IDE of CI integration, and so forth, so the idea is to write these long computation code in test from, group them in *studios* and extend pytest with a plugin that allow us to:\n\n- Ignore these long computation *studies* and run only the regular ones.\n- Sort all the involved tests so the *study* will be executed only when dependences are passed.\n- Define the *studies* and dependences in a easy way.\n- Don't interfere with normal pytest use.\n\n## Show me an example\n\nLet' say that we have this `test_studies.py` file:\n\n```python\nimport pytest\nimport time\n\n# You can put the regular tests and the studies in any order\n# pytest-study will reorder later\n\ndef test_independent():\n \"A regular isolated test\"\n time.sleep(0.05)\n\n# test marked as study will not be executed unless pass --runstudy\n# in command line\n\n@pytest.mark.study\ndef test_foo():\n \"This is a test that belongs to the default study\"\n time.sleep(0.1)\n print \"Inside foo test!\"\n assert True\n\n@pytest.mark.study\ndef test_study_one():\n \"\"\"This is a long run computation test that will be executed\n only if any previous test has been passed.\n \"\"\"\n time.sleep(0.2)\n print \"Study 1 Hello World!\"\n\n```\n\n## Usage\n\nThe following parameters are available from the command line\n\n\n```bash\n$ pytest --help\n\n... (other options are not shown) ...\n\ncustom options:\n --show_order show tests and studies order execution and which are\n selected for execution.\n --runstudy=all|reg expression\n regular expression for the studies names ('all' runs\n all). None is selected by default.\n```\n\nExecuting pytest showing the hooks trace would yield something like;\n\n```bash\n$ pytest --duration=10 --show_order\n====================================== test session starts =======================================\nplatform linux2 -- Python 2.7.13, pytest-3.2.2, py-1.4.34, pluggy-0.4.0\nplugins: study-0.12, timeout-1.2.0, testmon-0.9.6, race-0.1.1, pep8-1.0.6, cov-2.5.1, colordots-0.1, dependency-0.2\ncollected 3 items \n+ 0 [ ] tests/test_studies.py:test_independent\n- 1 [default] tests/test_studies.py:test_foo\n- 2 [default] tests/test_studies.py:test_study_one\n\ntests/test_studies.py .\n\n=================================== slowest 10 test durations ====================================\n0.05s call tests/test_studies.py::test_independent\n0.00s setup tests/test_studies.py::test_independent\n0.00s teardown tests/test_studies.py::test_independent\n==================================== 1 passed in 0.08 seconds ====================================\n\n```\n\nwhere only `test_indepent()` has been called (note the `call` tag) and the others are skipped from execution.\n\nNow, executing pytest with `--runstudy=all` we get show:\n\n```bash\n$ pytest --duration=10 --show_order --runstudy=all\n====================================== test session starts =======================================\nplatform linux2 -- Python 2.7.13, pytest-3.2.2, py-1.4.34, pluggy-0.4.0\nplugins: study-0.12, timeout-1.2.0, testmon-0.9.6, race-0.1.1, pep8-1.0.6, cov-2.5.1, colordots-0.1, dependency-0.2\ncollected 3 items \n+ 0 [ ] tests/test_studies.py:test_independent\n+ 1 [default] tests/test_studies.py:test_foo\n+ 2 [default] tests/test_studies.py:test_study_one\n\ntests/test_studies.py ...\n\n=================================== slowest 10 test durations ====================================\n0.20s call tests/test_studies.py::test_study_one\n0.10s call tests/test_studies.py::test_foo\n0.05s call tests/test_studies.py::test_independent\n0.00s setup tests/test_studies.py::test_independent\n0.00s teardown tests/test_studies.py::test_independent\n0.00s setup tests/test_studies.py::test_foo\n0.00s setup tests/test_studies.py::test_study_one\n0.00s teardown tests/test_studies.py::test_foo\n0.00s teardown tests/test_studies.py::test_study_one\n==================================== 3 passed in 0.38 seconds ====================================\n\n\n```\n\nwhere `test_foo()` and `test_study_one()` has been called as well.\nNote the `+` symbol at the beginning of each test shown by `--show_order` option.\n\n\n## Studies interdependences\n\nWe can add more test studies and group them by name and setting a relative priority for the studies executions with the keyword `order=`. The default priority is 1000, so any value lower will be executed first and the reverse is also true.\n\nAll prerequisites belonging to the same study with be ordered using the same criteria.\n\nLet's create a more rich example with a group named 'AI' and set some execution order:\n\n```python\nimport pytest\nimport time\n\n# make some 'alias'\nstudy = pytest.mark.study\npre = pytest.mark.pre\n\n# You can put the regular tests and the studies in any order\n# pytest-study will reorder later\n\n\ndef test_independent():\n \"A regular isolated test\"\n time.sleep(0.05)\n\n# test marked as study will not be executed unless pass --runstudy\n# in command line\n\n\n@pre(name='AI')\ndef test_foo():\n \"This is a prerequisite test that belongs to the 'AI' study\"\n time.sleep(0.1)\n print \"Inside foo test!\"\n assert True\n\n\n@pre(name='AI', order=5)\ndef test_gather_info():\n \"Another prerequisite for 'AI' study\"\n time.sleep(0.1)\n\n\n@study(name='AI')\ndef test_study_one():\n \"\"\"This is a long computation study that will be executed\n only if test_gather_info() and test_foo() has been passed (in that order)\n \"\"\"\n time.sleep(0.2)\n print \"Study 1 Hello World!\"\n\n\n@pre\ndef test_bar():\n \"This is a prerequisite test belonging to 'default' study\"\n time.sleep(0.15)\n print \"Inside bar test!\"\n assert True\n\n\n@pre(order=5)\ndef test_prior_bar():\n \"This is the prerequisite that is executed prior test_bar()\"\n time.sleep(0.15)\n\n\n@study(order=1)\ndef test_study_two():\n \"\"\"This studio will be executed before test_study_one because\n we have changed the order. All test_study_two() prerequisite will\n be executed before calling, but not test_study_one() prerequisites.\n\n This allows to execute the studies ASAP.\n \"\"\"\n time.sleep(0.3)\n print \"Study 2 Hello World again!\"\n\n```\n\nIf we execute pytest with the `--show_order` option as well, the output would be similar to:\n\n```bash\n$ pytest --duration=10 --show_order \n====================================== test session starts =======================================\nplatform linux2 -- Python 2.7.13, pytest-3.2.2, py-1.4.34, pluggy-0.4.0\nplugins: study-0.12, timeout-1.2.0, testmon-0.9.6, race-0.1.1, pep8-1.0.6, cov-2.5.1, colordots-0.1, dependency-0.2\ncollected 7 items \n+ 0 [ ] tests/test_studies.py:test_independent\n- 1 [default] tests/test_studies.py:test_prior_bar\n- 2 [default] tests/test_studies.py:test_bar\n- 3 [default] tests/test_studies.py:test_study_two\n- 4 [ AI] tests/test_studies.py:test_gather_info\n- 5 [ AI] tests/test_studies.py:test_foo\n- 6 [ AI] tests/test_studies.py:test_study_one\n\ntests/test_studies.py .\n\n=================================== slowest 10 test durations ====================================\n0.05s call tests/test_studies.py::test_independent\n0.00s setup tests/test_studies.py::test_independent\n0.00s teardown tests/test_studies.py::test_independent\n==================================== 1 passed in 0.08 seconds ====================================\n\n```\n\nwhere the sequence order, the selected flag and the name of associate study is show for each test.\n\nTo run a one or more studies we can use a regular expression that match the studio name.\n\n```bash\n$ pytest --duration=10 --show_order --runstudy='AI'\n====================================== test session starts =======================================\nplatform linux2 -- Python 2.7.13, pytest-3.2.2, py-1.4.34, pluggy-0.4.0\nplugins: study-0.12, timeout-1.2.0, testmon-0.9.6, race-0.1.1, pep8-1.0.6, cov-2.5.1, colordots-0.1, dependency-0.2\ncollected 7 items \n+ 0 [ ] tests/test_studies.py:test_independent\n+ 1 [ AI] tests/test_studies.py:test_gather_info\n+ 2 [ AI] tests/test_studies.py:test_foo\n+ 3 [ AI] tests/test_studies.py:test_study_one\n- 4 [default] tests/test_studies.py:test_prior_bar\n- 5 [default] tests/test_studies.py:test_bar\n- 6 [default] tests/test_studies.py:test_study_two\n\ntests/test_studies.py ....\n\n=================================== slowest 10 test durations ====================================\n0.20s call tests/test_studies.py::test_study_one\n0.10s call tests/test_studies.py::test_foo\n0.10s call tests/test_studies.py::test_gather_info\n0.05s call tests/test_studies.py::test_independent\n0.00s setup tests/test_studies.py::test_independent\n0.00s setup tests/test_studies.py::test_gather_info\n0.00s setup tests/test_studies.py::test_study_one\n0.00s setup tests/test_studies.py::test_foo\n0.00s teardown tests/test_studies.py::test_foo\n0.00s teardown tests/test_studies.py::test_independent\n==================================== 4 passed in 0.48 seconds ====================================\n```\n\n\n## Install\n\n```\n$ pip install pytest-study\n```\n\nor download and improve the code by yourself :) installing in develop mode in your home directory\n\n```\n python setup.py develop --user\n```\n\n\n## Python versions\n\nIs tested only in python 2.7 yet, but there is not any deliberated incompatibility with python 3.x versions.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/asteriogonzalez/pytest-study", "keywords": "testing,pytest,studies,long_run", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pytest-study", "package_url": "https://pypi.org/project/pytest-study/", "platform": "", "project_url": "https://pypi.org/project/pytest-study/", "project_urls": { "Homepage": "https://github.com/asteriogonzalez/pytest-study" }, "release_url": "https://pypi.org/project/pytest-study/0.14/", "requires_dist": [ "blessings", "pytest (>=2.0)" ], "requires_python": "", "summary": "A pytest plugin to organize long run tests (named studies) without interfering the regular tests", "version": "0.14" }, "last_serial": 3203411, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "69246f9b5c05c5a89bcfeed2a253b465", "sha256": "a26338911df71ac90645dedbe39d9e7c2c25a9268124861d0c87e14d6da1dcc9" }, "downloads": -1, "filename": "pytest_study-0.1-py2.7.egg", "has_sig": false, "md5_digest": "69246f9b5c05c5a89bcfeed2a253b465", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 3214, "upload_time": "2017-09-25T14:42:52", "url": "https://files.pythonhosted.org/packages/ee/1e/a8ed97e896a1b7efd0208781f0849e8d1c0069a1e071f3814f425288df09/pytest_study-0.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "893753ae770b3bebc601b5d56d0ed127", "sha256": "a21c3ed83691a0950ee0cea0987bf65372b92070f7718cbf658b1b53dda2ae58" }, "downloads": -1, "filename": "pytest_study-0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "893753ae770b3bebc601b5d56d0ed127", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6070, "upload_time": "2017-09-25T12:21:40", "url": "https://files.pythonhosted.org/packages/d8/66/cac04d6f13e3dbd4e2e60b84720618101c2f103c2d0d442485e57f6558b5/pytest_study-0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ce6137b4d087d54c89be5ad39ae377eb", "sha256": "5c7323a3dc6f9bdc13d3476449a86d99d62db4ceb1fa4e8dea1cf2fb2ca9512b" }, "downloads": -1, "filename": "pytest_study-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ce6137b4d087d54c89be5ad39ae377eb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6072, "upload_time": "2017-09-25T12:21:41", "url": "https://files.pythonhosted.org/packages/4d/32/0bdb8f44286dad1c60347a0c2797eb5f9aa9e52182c5544e094f3b7e1147/pytest_study-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6dd9aa3c3480f00f575ffac4bc2e5916", "sha256": "a1e97b5aa05df4d1ee409d413b20720daf13b3eb285eeaefc272c98d09b08093" }, "downloads": -1, "filename": "pytest-study-0.1.tar.gz", "has_sig": false, "md5_digest": "6dd9aa3c3480f00f575ffac4bc2e5916", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5418, "upload_time": "2017-09-25T12:21:43", "url": "https://files.pythonhosted.org/packages/fd/d8/28af6ca44e31415c41c2f1765a4bca4a9f87259305060803ffd3d072906d/pytest-study-0.1.tar.gz" } ], "0.11": [ { "comment_text": "", "digests": { "md5": "a2d8c485b14a85bca1e3efdd4766f502", "sha256": "14d542154c2177a4f864a63fcd76c7bdc20eefd235edf6f7897643355307c325" }, "downloads": -1, "filename": "pytest_study-0.11-py2-none-any.whl", "has_sig": false, "md5_digest": "a2d8c485b14a85bca1e3efdd4766f502", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 8643, "upload_time": "2017-09-25T14:42:44", "url": "https://files.pythonhosted.org/packages/79/9c/e7d655ede9de56b85e9da04d3abbbefd1767dd3c29a7fff2b48af5dfdf07/pytest_study-0.11-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ce66251f019465b50ddfd8cc5b36ee81", "sha256": "a71edbb82633f2fbbb73496aadd26281bbd35fef2c53f91559ecec55839ce054" }, "downloads": -1, "filename": "pytest-study-0.11.tar.gz", "has_sig": false, "md5_digest": "ce66251f019465b50ddfd8cc5b36ee81", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5662, "upload_time": "2017-09-25T14:42:49", "url": "https://files.pythonhosted.org/packages/80/5c/7208469fc988d04004f1865d24e46a24c9bf7224e28da68951bb5ee36ab5/pytest-study-0.11.tar.gz" } ], "0.12": [ { "comment_text": "", "digests": { "md5": "e441c92cf4d7e69c8e8f0dc95991c98c", "sha256": "c113ffdeac0bcb524e4172e4272239a0bbd3950552f9b4533418594ebe21b393" }, "downloads": -1, "filename": "pytest_study-0.12-py2-none-any.whl", "has_sig": false, "md5_digest": "e441c92cf4d7e69c8e8f0dc95991c98c", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 8794, "upload_time": "2017-09-25T14:42:45", "url": "https://files.pythonhosted.org/packages/ea/83/74ba65a319ab63697198f7ee3b35ba05de2aae5e6fb99a3c1d827f907da9/pytest_study-0.12-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0529a093bcfd72638fd4356e38a01d5a", "sha256": "0fe244beeef751072f04a8eecf046164ae3b852a18669913ef1678bae21dfc9f" }, "downloads": -1, "filename": "pytest-study-0.12.tar.gz", "has_sig": false, "md5_digest": "0529a093bcfd72638fd4356e38a01d5a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5753, "upload_time": "2017-09-25T14:42:50", "url": "https://files.pythonhosted.org/packages/f7/2e/3c3fa319c709336e9094533bec8b4870c9e22992af2c7501d3dc0db8104f/pytest-study-0.12.tar.gz" } ], "0.13": [ { "comment_text": "", "digests": { "md5": "157b060f016cacf575012487bb3b899e", "sha256": "b1e1d1a4b170813c97aba7dfcda61450ebdba2d59c8f7f74843380b79c10e7e3" }, "downloads": -1, "filename": "pytest_study-0.13-py2-none-any.whl", "has_sig": false, "md5_digest": "157b060f016cacf575012487bb3b899e", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9858, "upload_time": "2017-09-26T07:14:42", "url": "https://files.pythonhosted.org/packages/0d/20/b7c8aa233768127ce23bdefb4359e47959e38650204f590b6b8883153591/pytest_study-0.13-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2cf31e6cc9fc2943c7d3a3989b988fe3", "sha256": "fce11f6dfbcb2c8a7554767a99ebb4a2a9068a2f6b17d16aa89a5bbd14b76db6" }, "downloads": -1, "filename": "pytest-study-0.13.tar.gz", "has_sig": false, "md5_digest": "2cf31e6cc9fc2943c7d3a3989b988fe3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6640, "upload_time": "2017-09-26T07:14:44", "url": "https://files.pythonhosted.org/packages/4d/a0/c771e671f1b71139849336eeb8a43cca1287d38aab93c23f4edc8ea8bfb9/pytest-study-0.13.tar.gz" } ], "0.14": [ { "comment_text": "", "digests": { "md5": "e5ec5a0ac701189008d52bb9252c2281", "sha256": "f5e62a823da03e5bc49e844fdc2fc7510a37775c3efdeaa1692c1ca7d8351a9e" }, "downloads": -1, "filename": "pytest_study-0.14-py2-none-any.whl", "has_sig": false, "md5_digest": "e5ec5a0ac701189008d52bb9252c2281", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9856, "upload_time": "2017-09-26T09:21:58", "url": "https://files.pythonhosted.org/packages/e8/a1/e7a133fa7e14fcbb0f9f07d2273215920118d0f07ccfccae4e84c3b7abc5/pytest_study-0.14-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ba72c607113fea9a2fc77dd71f394c1b", "sha256": "dd5102be184383af5d843ba55cac799c57165403f2094a5b9cc897e79293b787" }, "downloads": -1, "filename": "pytest-study-0.14.tar.gz", "has_sig": false, "md5_digest": "ba72c607113fea9a2fc77dd71f394c1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6635, "upload_time": "2017-09-26T09:22:00", "url": "https://files.pythonhosted.org/packages/0e/e4/93a01be571863dbe02b4a3f6e26661e79338498b1c1dc88894dcb12fdb1a/pytest-study-0.14.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e5ec5a0ac701189008d52bb9252c2281", "sha256": "f5e62a823da03e5bc49e844fdc2fc7510a37775c3efdeaa1692c1ca7d8351a9e" }, "downloads": -1, "filename": "pytest_study-0.14-py2-none-any.whl", "has_sig": false, "md5_digest": "e5ec5a0ac701189008d52bb9252c2281", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9856, "upload_time": "2017-09-26T09:21:58", "url": "https://files.pythonhosted.org/packages/e8/a1/e7a133fa7e14fcbb0f9f07d2273215920118d0f07ccfccae4e84c3b7abc5/pytest_study-0.14-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ba72c607113fea9a2fc77dd71f394c1b", "sha256": "dd5102be184383af5d843ba55cac799c57165403f2094a5b9cc897e79293b787" }, "downloads": -1, "filename": "pytest-study-0.14.tar.gz", "has_sig": false, "md5_digest": "ba72c607113fea9a2fc77dd71f394c1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6635, "upload_time": "2017-09-26T09:22:00", "url": "https://files.pythonhosted.org/packages/0e/e4/93a01be571863dbe02b4a3f6e26661e79338498b1c1dc88894dcb12fdb1a/pytest-study-0.14.tar.gz" } ] }