mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-15 02:41:28 +00:00
Reimplement ubuntutools.subprocess.Popen as a class instead of a factory function.
This commit is contained in:
parent
d82e65e0e2
commit
5c96b78d72
@ -21,7 +21,8 @@ from subprocess import PIPE, STDOUT, CalledProcessError
|
|||||||
__all__ = ['Popen', 'call', 'check_call', 'check_output', 'CalledProcessError', 'PIPE', 'STDOUT']
|
__all__ = ['Popen', 'call', 'check_call', 'check_output', 'CalledProcessError', 'PIPE', 'STDOUT']
|
||||||
|
|
||||||
|
|
||||||
def Popen(*args, **kwargs):
|
class Popen(subprocess.Popen):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.setdefault('close_fds', True)
|
kwargs.setdefault('close_fds', True)
|
||||||
|
|
||||||
if 'restore_signals' not in inspect.getargspec(subprocess.Popen.__init__)[0]:
|
if 'restore_signals' not in inspect.getargspec(subprocess.Popen.__init__)[0]:
|
||||||
@ -38,7 +39,7 @@ def Popen(*args, **kwargs):
|
|||||||
given_preexec_fn()
|
given_preexec_fn()
|
||||||
kwargs['preexec_fn'] = preexec_fn
|
kwargs['preexec_fn'] = preexec_fn
|
||||||
|
|
||||||
return subprocess.Popen(*args, **kwargs)
|
subprocess.Popen.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
# call, check_call, and check_output are copied directly from the
|
# call, check_call, and check_output are copied directly from the
|
||||||
|
@ -28,8 +28,8 @@ WHITELIST = [re.compile(': %s$' % x) for x in (
|
|||||||
# mox:
|
# mox:
|
||||||
r"Instance of '.+' has no '(WithSideEffects|MultipleTimes|AndReturn)' "
|
r"Instance of '.+' has no '(WithSideEffects|MultipleTimes|AndReturn)' "
|
||||||
r"member",
|
r"member",
|
||||||
# Wrong Popen
|
# pylint doesn't like *args/**kwargs
|
||||||
r"Function 'Popen' has no '__init__' member",
|
r"Instance of 'Popen' has no '.*' member",
|
||||||
)]
|
)]
|
||||||
|
|
||||||
class PylintTestCase(unittest.TestCase):
|
class PylintTestCase(unittest.TestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user