MockProcess is a mock for the subprocess module to be used in your unit tests. Right now it only supports the check_output method, but eventually popen will be supported as well.
It is used via a context manager. Here’s a basic example
>>> import subprocess
>>> import unittest
>>> from mockprocess import MockCheckOutput
>>> class Test(unittest.TestCase):
... def test_simple(self):
... with MockCheckOutput('hello\n'):
... output = subprocess.check_output(['/bin/echo', 'hello'])
... self.assertEqual(output, 'hello\n')
...
If you need to test how you handle errors, you can set an exit code as well.
>>> import subprocess
>>> import unittest
>>> from mockprocess import MockCheckoutput
>>> class Test(unittest.TestCase):
... def test_exception(self):
... try:
... with MockCheckOutput('hello\n', exit_code=127):
... subprocess.check_output(['/bin/false'])
... except subprocess.CalledProcessError as exp:
... pass
... else:
... self.fail('exception was not raised')
Metadata
Release files for mockprocess 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mockprocess-0.2.tar.gz | 2.2 kB | Without provenance | Details for mockprocess-0.2.tar.gz |
Release files / mockprocess-0.2.tar.gz
| Download URL | mockprocess-0.2.tar.gz |
|---|---|
| Size | 2.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
305ac8a0f36713af528368676bd1c015d9f49a8853a73dc531b68ef63726aa40
|
|
BLAKE2b-256 checksum How to use checksums |
61a6f824b0b8f00273a939b65b08b7c419c89c07b77e2247d196d1d14fb59c10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for mockprocess 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.