Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distributed various elements into separate files #69

Merged
merged 5 commits into from
Jan 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ processes with real ``subprocess``, or use
.. code-block:: python

def test_real_process(fake_process):
with pytest.raises(pytest_subprocess.ProcessNotRegisteredError):
with pytest.raises(fake_process.exceptions.ProcessNotRegisteredError):
# this will fail, as "ls" command is not registered
subprocess.call("ls")

Expand Down Expand Up @@ -170,7 +170,7 @@ which will keep the last registered process forever.
assert second_process.returncode == 1

# 3rd time shall raise an exception
with pytest.raises(pytest_subprocess.ProcessNotRegisteredError):
with pytest.raises(fake_process.exceptions.ProcessNotRegisteredError):
subprocess.check_call("test")

# now, register two processes once again,
Expand Down Expand Up @@ -248,7 +248,7 @@ it somewhere else.
.. code-block:: python

def test_context_manager(fake_process):
with pytest.raises(pytest_subprocess.ProcessNotRegisteredError):
with pytest.raises(fake_process.exceptions.ProcessNotRegisteredError):
# command not registered, so will raise an exception
subprocess.check_call("test")

Expand All @@ -260,7 +260,7 @@ it somewhere else.

# the command was called 2 times, so one occurrence left, but since the
# context manager has been left, it is not registered anymore
with pytest.raises(pytest_subprocess.ProcessNotRegisteredError):
with pytest.raises(fake_process.exceptions.ProcessNotRegisteredError):
subprocess.check_call("test")

Non-exact command matching
Expand All @@ -287,7 +287,7 @@ if the subprocess command will be called with a string argument.
# but it can force a minimum amount of arguments
fake_process.register_subprocess(["cp", fake_process.any(min=2)])

with pytest.raises(pytest_subprocess.ProcessNotRegisteredError):
with pytest.raises(fake_process.exceptions.ProcessNotRegisteredError):
# only one argument is used, so registered command won't match
subprocess.check_call("cp /source/dir")
# but two arguments will be fine
Expand All @@ -296,7 +296,7 @@ if the subprocess command will be called with a string argument.
# the `max` argument can be used to limit maximum amount of arguments
fake_process.register_subprocess(["cd", fake_process.any(max=1)])

with pytest.raises(pytest_subprocess.ProcessNotRegisteredError):
with pytest.raises(fake_process.exceptions.ProcessNotRegisteredError):
# cd with two arguments won't match with max=1
subprocess.check_call("cd ~/ /tmp")
# but any single argument is fine
Expand Down
5 changes: 5 additions & 0 deletions changelog.d/other.46c33788.entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
message: Extracted code into separate files to improve navigation.
pr_ids:
- '69'
timestamp: 1642333772
type: other
10 changes: 6 additions & 4 deletions pytest_subprocess/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Main module"""

from .core import FakeProcess
from .core import IncorrectProcessDefinition
from .core import ProcessNotRegisteredError
from . import exceptions
from .fake_process import FakeProcess

__all__ = ["FakeProcess", "ProcessNotRegisteredError", "IncorrectProcessDefinition"]
ProcessNotRegisteredError = exceptions.ProcessNotRegisteredError

__all__ = ["FakeProcess", "exceptions", "ProcessNotRegisteredError"]
Loading