diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-02-14 09:27:27 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-02-14 09:27:27 -0500 |
commit | e46e6e0ff56104f137678fa712b7b4f78b25cea8 (patch) | |
tree | 5b4db7a4857fe6d0b9041f167587352e9a2b89ac /tests/helpers.py | |
parent | d53ee24128c59babdce7902102671cc3c0d9e950 (diff) | |
download | python-coveragepy-e46e6e0ff56104f137678fa712b7b4f78b25cea8.tar.gz |
Move some code to where it belongs
Diffstat (limited to 'tests/helpers.py')
-rw-r--r-- | tests/helpers.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/helpers.py b/tests/helpers.py index db20d79..c26f485 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -1,5 +1,31 @@ """Helpers for coverage.py tests.""" +import subprocess + + +# This isn't really a backward compatibility thing, should be moved into a +# helpers file or something. +def run_command(cmd): + """Run a command in a sub-process. + + Returns the exit status code and the combined stdout and stderr. + + """ + proc = subprocess.Popen( + cmd, shell=True, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT + ) + output, _ = proc.communicate() + status = proc.returncode + + # Get the output, and canonicalize it to strings with newlines. + if not isinstance(output, str): + output = output.decode('utf-8') + output = output.replace('\r', '') + + return status, output + class CheckUniqueFilenames(object): """Asserts the uniqueness of filenames passed to a function.""" |