@@ -223,7 +223,7 @@ def check_output(
223223 >>> cmd = SubprocessCommand(args=['echo', 'hello'])
224224 >>> proc = cmd.check_output(shell=True)
225225
226- From :mod:`subprocess`:
226+ Examples from :mod:`subprocess`:
227227
228228 >>> import subprocess
229229 >>> cmd = SubprocessCommand(
@@ -247,7 +247,7 @@ def run(
247247 capture_output : bool = False ,
248248 ** kwargs ,
249249 ) -> subprocess .CompletedProcess :
250- """Run command in :func:`subprocess.run`, optionally overrides via kwargs.
250+ r """Run command in :func:`subprocess.run`, optionally overrides via kwargs.
251251
252252 Parameters
253253 ----------
@@ -268,6 +268,39 @@ def run(
268268
269269 **kwargs : dict, optional
270270 Overrides existing attributes for :func:`subprocess.run`
271+
272+ Examples
273+ --------
274+ >>> import subprocess
275+ >>> cmd = SubprocessCommand(
276+ ... ["/bin/sh", "-c", "ls -l non_existent_file ; exit 0"])
277+ >>> cmd.run()
278+ CompletedProcess(args=['/bin/sh', '-c', 'ls -l non_existent_file ; exit 0'],
279+ returncode=0)
280+
281+ >>> import subprocess
282+ >>> cmd = SubprocessCommand(
283+ ... ["/bin/sh", "-c", "ls -l non_existent_file ; exit 0"])
284+ >>> cmd.run(check=True)
285+ CompletedProcess(args=['/bin/sh', '-c', 'ls -l non_existent_file ; exit 0'],
286+ returncode=0)
287+
288+ >>> cmd = SubprocessCommand(["sed", "-e", "s/foo/bar/"])
289+ >>> completed = cmd.run(input=b"when in the course of fooman events\n")
290+ >>> completed
291+ CompletedProcess(args=['sed', '-e', 's/foo/bar/'], returncode=0)
292+ >>> completed.stderr
293+
294+ >>> cmd = SubprocessCommand(["sed", "-e", "s/foo/bar/"])
295+ >>> completed = cmd.run(input=b"when in the course of fooman events\n",
296+ ... capture_output=True)
297+ >>> completed
298+ CompletedProcess(args=['sed', '-e', 's/foo/bar/'], returncode=0,
299+ stdout=b'when in the course of barman events\n', stderr=b'')
300+ >>> completed.stdout
301+ b'when in the course of barman events\n'
302+ >>> completed.stderr
303+ b''
271304 """
272305 return subprocess .run (
273306 ** dataclasses .replace (self , ** kwargs ).__dict__ ,
0 commit comments