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/sources/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/sources/git.py')
-rw-r--r-- | tests/sources/git.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/sources/git.py b/tests/sources/git.py index 40df30ac6..1f05055e4 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -869,15 +869,15 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type): else: options = ['--tags'] describe = subprocess.check_output(['git', 'describe', *options], - cwd=checkout).decode('ascii') + cwd=checkout, universal_newlines=True) assert describe.startswith('tag2-2-') describe_fp = subprocess.check_output(['git', 'describe', '--first-parent', *options], - cwd=checkout).decode('ascii') + cwd=checkout, universal_newlines=True) assert describe_fp.startswith('tag1-2-') tags = subprocess.check_output(['git', 'tag'], - cwd=checkout).decode('ascii') + cwd=checkout, universal_newlines=True) tags = set(tags.splitlines()) assert tags == set(['tag1', 'tag2']) @@ -979,16 +979,18 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty else: options = ['--tags'] describe = subprocess.check_output(['git', 'describe', *options], - cwd=checkout).decode('ascii') + cwd=checkout, universal_newlines=True) assert describe.startswith('tag') tags = subprocess.check_output(['git', 'tag'], - cwd=checkout).decode('ascii') + cwd=checkout, + universal_newlines=True) tags = set(tags.splitlines()) assert tags == set(['tag']) rev_list = subprocess.check_output(['git', 'rev-list', '--all'], - cwd=checkout).decode('ascii') + cwd=checkout, + universal_newlines=True) assert set(rev_list.splitlines()) == set([tagged_ref]) @@ -1066,11 +1068,13 @@ def test_git_describe_relevant_history(cli, tmpdir, datafiles): result.assert_success() describe = subprocess.check_output(['git', 'describe'], - cwd=checkout).decode('ascii') + cwd=checkout, + universal_newlines=True) assert describe.startswith('tag1-2-') rev_list = subprocess.check_output(['git', 'rev-list', '--all'], - cwd=checkout).decode('ascii') + cwd=checkout, + universal_newlines=True) assert set(rev_list.splitlines()) == set([head, tagged_ref, branch_boundary]) |