subprocess-mock


Namesubprocess-mock JSON
Version 0.4.4 PyPI version JSON
download
home_page
SummarySubprocess Mock
upload_time2024-02-19 07:52:41
maintainer
docs_urlNone
author
requires_python>=3.6
licenseMIT 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": "",
    "name": "subprocess-mock",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "unittest,mock,subprocess",
    "author": "",
    "author_email": "Rainer Schwarzbach <rainer@blackstream.de>",
    "download_url": "https://files.pythonhosted.org/packages/93/ee/1a282c074a9d66fac077de042914c41ee3a12a20113953c79528e7eff686/subprocess-mock-0.4.4.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.4",
    "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": "6c44d7dcf160adbdf64236f81300fb3ccd54457f7f2a02bcdd505b682f6d7b72",
                "md5": "1b5466efdcd0dd593726fcb7496631bd",
                "sha256": "0617300c0e0817b6b5e0e7f8e02d048f025506bccf8370bad17c9bb1daf17c30"
            },
            "downloads": -1,
            "filename": "subprocess_mock-0.4.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1b5466efdcd0dd593726fcb7496631bd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 28963,
            "upload_time": "2024-02-19T07:52:39",
            "upload_time_iso_8601": "2024-02-19T07:52:39.613981Z",
            "url": "https://files.pythonhosted.org/packages/6c/44/d7dcf160adbdf64236f81300fb3ccd54457f7f2a02bcdd505b682f6d7b72/subprocess_mock-0.4.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "93ee1a282c074a9d66fac077de042914c41ee3a12a20113953c79528e7eff686",
                "md5": "15296a5bfead3005ace9b32a606d7fc8",
                "sha256": "a8125a1bc597e0e0255c5b1a7ef7cbef8c5822cd495326fc3f6d9c9e8d72eafc"
            },
            "downloads": -1,
            "filename": "subprocess-mock-0.4.4.tar.gz",
            "has_sig": false,
            "md5_digest": "15296a5bfead3005ace9b32a606d7fc8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 28340,
            "upload_time": "2024-02-19T07:52:41",
            "upload_time_iso_8601": "2024-02-19T07:52:41.076252Z",
            "url": "https://files.pythonhosted.org/packages/93/ee/1a282c074a9d66fac077de042914c41ee3a12a20113953c79528e7eff686/subprocess-mock-0.4.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-19 07:52:41",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "blackstream-x",
    "gitlab_project": "subprocess-mock",
    "lcname": "subprocess-mock"
}
        
Elapsed time: 0.19691s