1. Vinay Sajip
  2. sarge
  3. Pull requests

Pull requests

#1 Open
Repository
westurner
Branch
check_returncode
Repository
vinay.sajip
Branch
default

ENH: Add call, check_call, check_output, CalledProcessError, expect_returncode (#26)

Bitbucket cannot automatically merge this request.

The commits that make up this pull request have been removed.

Bitbucket cannot automatically merge this request due to conflicts.

Review the conflicts on the Overview tab. You can then either decline the request or merge it manually on your local system using the following commands:

hg update default
hg pull -r check_returncode https://bitbucket.org/westurner/sarge
hg merge check_returncode
hg commit -m 'Merged in westurner/sarge/check_returncode (pull request #1)'
Author
  1. Wes Turner
Reviewers
Description
  • expect_returncode
  • subprocess compat
* Added an ``expect_returncode`` kwarg to ``run()`` which accepts an int, tuple, or list
  of expected returncode(s) and
  raises ``sarge.CalledProcessError(subprocess.CalledProcessError)``
  if they are not the same
* Added ``call``, ``check_call``, and ``check_output`` functions
  which work similarly to the subprocess functions of the same names

Comments (11)

  1. Wes Turner author

    ... check_call with async=True ->

    ERROR: test_sarge:SargeTest.test_check_call_async
      e +722  test_sarge.py  # test_check_call_async
        returncode = check_call(('echo', 'hello'), async=True, stdout=out)
      e +1539 sarge/__init__.py  # check_call
        return call(cmd, **kwargs)
      e +1521 sarge/__init__.py  # call
        p = run(cmd, **kwargs)
      e +1447 sarge/__init__.py  # run
        p.run(input=input, async=True, expect_returncode=expect_returncode)
      e +1070 sarge/__init__.py  # run
        if self.returncode != expect_returncode:
      e +1084 sarge/__init__.py  # returncode
        return self.commands[-1].process.returncode
    AttributeError: 'NoneType' object has no attribute 'returncode'
    
  2. Wes Turner author

    Updated the PR: call, check_call, and check_output now raise ValueError when async=True

        def test_check_call_output__async_raises(self):
            for func in [call, check_call, check_output]:
                with Capture() as out:
                    self.assertRaises(ValueError,
                        func, ('echo', 'hello'),
                                    async=True,
                                    stdout=out)
    
  3. Vinay Sajip repo owner

    Will take a look - this had gone off my radar. I will probably do a slightly different implementation and am not sure I will merge this exactly as is (even if merge conflicts are resolved).