{ "info": { "author": "Daniel Murray", "author_email": "daniel@darkdisco.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Pytest", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Testing" ], "description": "============\npytest-shell\n============\n\nA plugin for testing shell scripts and line-based processes with pytest.\n\nYou could use it to test shell scripts, or other commands that can be run\nthrough the shell that you want to test the usage of.\n\nNot especially feature-complete or even well-tested, but works for what I\nwanted it for. If you use it please feel free to file bug reports or feature\nrequests.\n\n----\n\nThis `pytest`_ plugin was generated with `Cookiecutter`_ along with\n`@hackebrot`_'s `cookiecutter-pytest-plugin`_ template.\n\n\nFeatures\n--------\n\n* Easy access to a bash shell through a pytest fixture.\n* Set and check environment variables through Python code.\n* Automatically fail test on nonzero return codes by default.\n* Helpers for running shell scripts.\n* Mostly, all the great stuff pytest gives you with a few helpers to make it\n work for bash.\n\n\nInstallation\n------------\n\nYou can install \"pytest-shell\" via `pip`_ from `PyPI`_::\n\n $ pip install pytest-shell\n\nUsage\n-----\n\nYou can use a fixture called 'bash' to get a shell process you can interact\nwith.\n\nTest a bash function::\n\n def test_something(bash):\n assert bash.run_function('test') == 'expected output'\n\nSet environment variables, run a .sh file and check results::\n\n def test_something(bash):\n with bash(envvars={'SOMEDIR': '/home/blah'}) as s:\n s.run_script('dostuff.sh', ['arg1', 'arg2'])\n assert s.path_exists('/home/blah/newdir')\n assert s.file_contents('/home/blah/newdir/test.txt') == 'test text'\n\nRun some inline script, check an environment variable was set::\n\n def test_something(bash):\n bash.run_script_inline(['touch /tmp/blah.txt', './another_script.sh'])\n assert bash.envvars.get('AVAR') == 'success'\n\nUse context manager to set environment variables::\n\n def test_something(bash):\n with bash(envvars={'BLAH2': 'something'}):\n assert bash.envvars['BLAH2'] == 'something'\n\nYou can run things other than bash (ssh for example), but there aren't specific\nfixtures and the communication with the process is very bash-specific.\n\nCreating file and directory structures\n--------------------------------------\n\npytest_shell.fs.create_files() is a helper to assemble a structure of files and\ndirectories. It is best used with the tmpdir pytest fixture so you don't have\nto clean up. It is used like so::\n\n structure = ['/a/directory',\n {'/a/directory/and/a/file.txt': {'content': 'blah'}},\n {'/a/directory/and': {'mode': 0o600}]\n create_files(structure)\n\nwhich should create something like this::\n\n |\n + a\n \\\n + directory\n \\\n + and # mode 600\n \\\n + a\n \\\n file.txt # content equal to 'blah'\n\nchroot helper\n-------------\n\nA context manager that creates a chroot environment is available through\nthe bash fixture::\n\n with bash.chroot(tmpdir):\n bash.send('mkdir /blah')\n\nThe only reason to use this is if you need to test something that relies on a\ncertain path structure anchored at root. It is fairly flimsy, and of course\nrequires sudo. The best way to use it is with the tmpdir fixture provided by\npytest as no cleanup is done.\n\n/bin, /usr/bin, /lib and /lib64 are mounted into the chroot using a bind mount,\notherwise most things don't work. The chroot commands is called with --userspec\nfor the current user so the commands you run in there won't be run as root,\nbut nevertheless be careful and aware that the directories mounted in there are\nyour real system directories. There is no safety or security, it's just a\nhelper to test something that would be otherwise hard to test.\n\n\nTODO\n----\n\n* Helpers for piping, streaming.\n* Fixtures and helpers for docker and ssh.\n* Support for non-bash shells.\n* Shell instance in setup for e.g. basepath.\n\n\nRefactoring TODO\n----------------\n\n* Make Connection class just handle bytes, move line-based stuff into an\n intermediary.\n* Make pattern stuff work line-based or on multiline streams (in a more\n obvious way than just crafting the right regexes).\n* Make pattern stuff work on part of line if desired, leaving the rest.\n\nLicense\n-------\n\nDistributed under the terms of the `MIT`_ license, \"pytest-shell\" is free and\nopen source software\n\n.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter\n.. _`@hackebrot`: https://github.com/hackebrot\n.. _`MIT`: http://opensource.org/licenses/MIT\n.. _`BSD-3`: http://opensource.org/licenses/BSD-3-Clause\n.. _`GNU GPL v3.0`: http://www.gnu.org/licenses/gpl-3.0.txt\n.. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0\n.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin\n.. _`file an issue`: https://github.com/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}/issues\n.. _`pytest`: https://github.com/pytest-dev/pytest\n.. _`tox`: https://tox.readthedocs.io/en/latest/\n.. _`pip`: https://pypi.org/project/pip/\n.. _`PyPI`: https://pypi.org/project\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://hg.sr.ht/~danmur/pytest-shell", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pytest-shell", "package_url": "https://pypi.org/project/pytest-shell/", "platform": "", "project_url": "https://pypi.org/project/pytest-shell/", "project_urls": { "Homepage": "https://hg.sr.ht/~danmur/pytest-shell" }, "release_url": "https://pypi.org/project/pytest-shell/0.2.1/", "requires_dist": [ "pytest (>=3.5.0)" ], "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "summary": "A plugin for testing shell scripts and line-based processes with pytest", "version": "0.2.1" }, "last_serial": 5741953, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "84a1db5f43b7f5421b16307dd8ac5143", "sha256": "0839d3c35bde19e4cc63139e256f12c48b6c786229d61ba2316fdadee12a0695" }, "downloads": -1, "filename": "pytest_shell-0.1.0-py2-none-any.whl", "has_sig": false, "md5_digest": "84a1db5f43b7f5421b16307dd8ac5143", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "size": 11463, "upload_time": "2018-08-06T13:24:30", "url": "https://files.pythonhosted.org/packages/be/dc/1821a7bde3f49da8089a751f21a56fd4c65ae4e7f9c28284e9fcafdb4bdb/pytest_shell-0.1.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "633702e702e0945987074034f7a57613", "sha256": "0fd616625714749dda56677705e533ecf30f9559c8fd4468f6d6d2777db55e6f" }, "downloads": -1, "filename": "pytest-shell-0.1.0.tar.gz", "has_sig": false, "md5_digest": "633702e702e0945987074034f7a57613", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "size": 9442, "upload_time": "2018-08-06T13:24:32", "url": "https://files.pythonhosted.org/packages/f6/03/c53885b44ecf3700a867b1c8df8fa6a6971731e538864edabce3a08b9eb7/pytest-shell-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "e5c817a5cdf87aa5c7f7fe2543b20be7", "sha256": "f669bf6fd17055457bffb32a8ae17bf0eb787e926201b5b17215a8afb761ccc9" }, "downloads": -1, "filename": "pytest_shell-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e5c817a5cdf87aa5c7f7fe2543b20be7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "size": 11942, "upload_time": "2018-10-18T04:19:44", "url": "https://files.pythonhosted.org/packages/a8/71/530e9b491ed3f29bcd35085d2e89b007c24cd78162814112ce9166d7ee78/pytest_shell-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5fc17b182d69a5e37df00c6182ac74b2", "sha256": "13433a4fc8494518aa2dabb75d4a27e53bce6f9e2cfffa933e62627f27a1044b" }, "downloads": -1, "filename": "pytest-shell-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5fc17b182d69a5e37df00c6182ac74b2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "size": 9338, "upload_time": "2018-10-18T04:19:46", "url": "https://files.pythonhosted.org/packages/34/75/a560a6086ef5a73d8f7c2f3789f5483f7db5f62cf55b0e53d9fd3bb41196/pytest-shell-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "03e5e0185338a22a09400e22adfacf8c", "sha256": "5268678e09d9d72892697b03d5f9eb0c3b47bc3335d507c9da82391429d9384b" }, "downloads": -1, "filename": "pytest-shell-0.2.0.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "03e5e0185338a22a09400e22adfacf8c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "size": 20774, "upload_time": "2019-06-15T02:24:17", "url": "https://files.pythonhosted.org/packages/75/3d/0f4370af99affba54750d7edf4286c0d59fd16012ade636687e6d03568ce/pytest-shell-0.2.0.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "131cdcbe5f45315e5bcbe4173c93f41e", "sha256": "d3de5c73bdc196043885e769cc7a32347192308a770d4d99699858437e69a2e6" }, "downloads": -1, "filename": "pytest_shell-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "131cdcbe5f45315e5bcbe4173c93f41e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "size": 14606, "upload_time": "2019-06-15T02:24:14", "url": "https://files.pythonhosted.org/packages/7c/ab/4217a3a00018375a729283c459b2a0ac0a74d6973c2829d929c2aa3653e9/pytest_shell-0.2.0-py3-none-any.whl" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "e9cf2a0a4a9c35547c2308ee85a45be3", "sha256": "6452add37a53ff55ccde47da245dedc103733e5ff239e35fc577a32832df6ea1" }, "downloads": -1, "filename": "pytest_shell-0.2.1-py2-none-any.whl", "has_sig": false, "md5_digest": "e9cf2a0a4a9c35547c2308ee85a45be3", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "size": 16961, "upload_time": "2019-08-28T11:22:47", "url": "https://files.pythonhosted.org/packages/58/62/8450f440cad4240356f6a4cf63e7f14d1ba22c920a02e05461580af5119c/pytest_shell-0.2.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "af6831d0bb5287a4c1af47ee0b52ecdd", "sha256": "e897aee66caeeed50836a16aaf813ad3399bdebaf048cece22bcd9d982b9b828" }, "downloads": -1, "filename": "pytest-shell-0.2.1.tar.gz", "has_sig": false, "md5_digest": "af6831d0bb5287a4c1af47ee0b52ecdd", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "size": 13882, "upload_time": "2019-08-28T11:22:50", "url": "https://files.pythonhosted.org/packages/69/3e/2417001318aee58cd65f632cdf9623cc2188bd43f6e173a41399e50d2016/pytest-shell-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e9cf2a0a4a9c35547c2308ee85a45be3", "sha256": "6452add37a53ff55ccde47da245dedc103733e5ff239e35fc577a32832df6ea1" }, "downloads": -1, "filename": "pytest_shell-0.2.1-py2-none-any.whl", "has_sig": false, "md5_digest": "e9cf2a0a4a9c35547c2308ee85a45be3", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "size": 16961, "upload_time": "2019-08-28T11:22:47", "url": "https://files.pythonhosted.org/packages/58/62/8450f440cad4240356f6a4cf63e7f14d1ba22c920a02e05461580af5119c/pytest_shell-0.2.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "af6831d0bb5287a4c1af47ee0b52ecdd", "sha256": "e897aee66caeeed50836a16aaf813ad3399bdebaf048cece22bcd9d982b9b828" }, "downloads": -1, "filename": "pytest-shell-0.2.1.tar.gz", "has_sig": false, "md5_digest": "af6831d0bb5287a4c1af47ee0b52ecdd", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", "size": 13882, "upload_time": "2019-08-28T11:22:50", "url": "https://files.pythonhosted.org/packages/69/3e/2417001318aee58cd65f632cdf9623cc2188bd43f6e173a41399e50d2016/pytest-shell-0.2.1.tar.gz" } ] }