Name | subprocess-mock JSON |
Version |
0.4.5
JSON |
| download |
home_page | None |
Summary | Subprocess Mock |
upload_time | 2024-05-20 10:42:30 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.6 |
license | MIT License Copyright (c) 2024 Rainer Schwarzbach Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
unittest
mock
subprocess
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Subprocess Mock
_Mock objects for the standard library’s subprocess module_
```
pip install subprocess-mock
```
Installation in a virtual environment is recommended.
## Example Usage
Use the functions defined in the **subprocess\_mock.functions** module
(and also exposed in the **subprocess_mock** namespace) to patch
subprocess module functions in unit tests.
```python
>>> import pathlib
>>> import subprocess
>>> import subprocess_mock
>>> from unittest.mock import patch
>>>
>>> new_file = pathlib.Path("testfile.txt")
>>> new_file.exists()
False
>>> # Test: call a process with a mock.patched subprocess.run
>>> # No Process is called,
>>> # but a subprocess.CompletedProcess instance is returned.
>>>
>>> with patch("subprocess.run", new=subprocess_mock.run):
... run_result = subprocess.run(["touch", str(new_file)])
...
>>> run_result
CompletedProcess(args=['touch', 'testfile.txt'], returncode=0)
>>> new_file.exists()
False
>>>
>>> # Counter-test: call the process without patching subprocess.run
>>> # The process is called with normal effects.
>>>
>>> run_result = subprocess.run(["touch", str(new_file)])
>>> new_file.exists()
True
>>>
```
## Further reading
Please see the documentation at <https://blackstream-x.gitlab.io/subprocess-mock>
for detailed usage information.
If you found a bug or have a feature suggestion,
please open an issue [here](https://gitlab.com/blackstream-x/subprocess-mock/-/issues)
Raw data
{
"_id": null,
"home_page": null,
"name": "subprocess-mock",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "unittest, mock, subprocess",
"author": null,
"author_email": "Rainer Schwarzbach <rainer@blackstream.de>",
"download_url": "https://files.pythonhosted.org/packages/6e/28/6767d9e9d135f7e657661d42c655484d743f4d5bbad3e4104c9daa27313a/subprocess_mock-0.4.5.tar.gz",
"platform": null,
"description": "# Subprocess Mock\n\n_Mock objects for the standard library\u2019s subprocess module_\n\n```\npip install subprocess-mock\n```\n\nInstallation in a virtual environment is recommended.\n\n\n## Example Usage\n\nUse the functions defined in the **subprocess\\_mock.functions** module\n(and also exposed in the **subprocess_mock** namespace) to patch\nsubprocess module functions in unit tests.\n\n\n```python\n>>> import pathlib\n>>> import subprocess\n>>> import subprocess_mock\n>>> from unittest.mock import patch\n>>>\n>>> new_file = pathlib.Path(\"testfile.txt\")\n>>> new_file.exists()\nFalse\n>>> # Test: call a process with a mock.patched subprocess.run\n>>> # No Process is called,\n>>> # but a subprocess.CompletedProcess instance is returned.\n>>>\n>>> with patch(\"subprocess.run\", new=subprocess_mock.run):\n... run_result = subprocess.run([\"touch\", str(new_file)])\n...\n>>> run_result\nCompletedProcess(args=['touch', 'testfile.txt'], returncode=0)\n>>> new_file.exists()\nFalse\n>>>\n>>> # Counter-test: call the process without patching subprocess.run\n>>> # The process is called with normal effects.\n>>>\n>>> run_result = subprocess.run([\"touch\", str(new_file)])\n>>> new_file.exists()\nTrue\n>>>\n```\n\n\n## Further reading\n\nPlease see the documentation at <https://blackstream-x.gitlab.io/subprocess-mock>\nfor detailed usage information.\n\nIf you found a bug or have a feature suggestion,\nplease open an issue [here](https://gitlab.com/blackstream-x/subprocess-mock/-/issues)\n\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Rainer Schwarzbach Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Subprocess Mock",
"version": "0.4.5",
"project_urls": {
"Bug Tracker": "https://gitlab.com/blackstream-x/subprocess-mock/-/issues",
"CI": "https://gitlab.com/blackstream-x/subprocess-mock/-/pipelines",
"Documentation": "https://blackstream-x.gitlab.io/subprocess-mock",
"Homepage": "https://gitlab.com/blackstream-x/subprocess-mock",
"Repository": "https://gitlab.com/blackstream-x/subprocess-mock.git"
},
"split_keywords": [
"unittest",
" mock",
" subprocess"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "905aea7c98eff0a0319b2583bb2f352744c9cc33454b9e76a71ab5ca4c98805c",
"md5": "521308ee6f2672103edea6fe231feb6e",
"sha256": "fd360d08b91a3783d92a6b071982b5a97a6a4fc4c51ff5747767d8e88feeb400"
},
"downloads": -1,
"filename": "subprocess_mock-0.4.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "521308ee6f2672103edea6fe231feb6e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 28853,
"upload_time": "2024-05-20T10:42:28",
"upload_time_iso_8601": "2024-05-20T10:42:28.606739Z",
"url": "https://files.pythonhosted.org/packages/90/5a/ea7c98eff0a0319b2583bb2f352744c9cc33454b9e76a71ab5ca4c98805c/subprocess_mock-0.4.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6e286767d9e9d135f7e657661d42c655484d743f4d5bbad3e4104c9daa27313a",
"md5": "390ee79409bb4b163bc718fc64dbf959",
"sha256": "fb5b0929704c213e1e888fa7322bae6357f5c2e4c766fc438c3846d6d2034046"
},
"downloads": -1,
"filename": "subprocess_mock-0.4.5.tar.gz",
"has_sig": false,
"md5_digest": "390ee79409bb4b163bc718fc64dbf959",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 28197,
"upload_time": "2024-05-20T10:42:30",
"upload_time_iso_8601": "2024-05-20T10:42:30.353965Z",
"url": "https://files.pythonhosted.org/packages/6e/28/6767d9e9d135f7e657661d42c655484d743f4d5bbad3e4104c9daa27313a/subprocess_mock-0.4.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-20 10:42:30",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "blackstream-x",
"gitlab_project": "subprocess-mock",
"lcname": "subprocess-mock"
}