diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-03-01 10:35:15 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-01 20:58:29 +0000 |
commit | 5264b9093876a595d9c69892c5124f2fc55804e6 (patch) | |
tree | 41295665dfa216377f40baa93076ff6b58ef23ad /tests/testutils/repo/git.py | |
parent | d223c8f416aa5fe7fdf805baccf5a33e2a6c9992 (diff) | |
download | buildstream-bschubert/no-subprocess-decode.tar.gz |
Let subprocess decode stdout based on localebschubert/no-subprocess-decode
Subprocesses can return decoded strings if we give them a
"universal_newlines=True" argument. We can therefore offload that to
them, and not explicitly decode output ourselves.
This also fixes multiple bugs where we would not be respecting the
locale used by the user, and in some cases force it to "ascii".
Diffstat (limited to 'tests/testutils/repo/git.py')
-rw-r--r-- | tests/testutils/repo/git.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/testutils/repo/git.py b/tests/testutils/repo/git.py index 9f617a763..12384e052 100644 --- a/tests/testutils/repo/git.py +++ b/tests/testutils/repo/git.py @@ -98,8 +98,11 @@ class Git(Repo): return config def latest_commit(self): - output = self._run_git('rev-parse', 'HEAD', stdout=subprocess.PIPE).stdout - return output.decode('UTF-8').strip() + return self._run_git( + 'rev-parse', 'HEAD', + stdout=subprocess.PIPE, + universal_newlines=True, + ).stdout.strip() def branch(self, branch_name): self._run_git('checkout', '-b', branch_name) @@ -115,5 +118,8 @@ class Git(Repo): return self.latest_commit() def rev_parse(self, rev): - output = self._run_git('rev-parse', rev, stdout=subprocess.PIPE).stdout - return output.decode('UTF-8').strip() + return self._run_git( + 'rev-parse', rev, + stdout=subprocess.PIPE, + universal_newlines=True, + ).stdout.strip() |