summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2019-08-27 10:26:47 +0100
committerStephen Finucane <sfinucan@redhat.com>2019-08-27 16:57:23 +0100
commitdfe67959e662d6f6b116262b08922af17ac67e72 (patch)
tree9410f783256b1d7536a65f94fdfe1b2c41dd8aed
parent57d7c53739487e9fa0051ae12d8609acebaaf0e1 (diff)
downloadpbr-5.4.4.tar.gz
trivial: Use 'open' context manager5.4.4
It's a little nicer to look at. Change-Id: If5bc9b7e3927fe3203ba9adadaa1185c4a1cc7ed Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
-rw-r--r--pbr/tests/test_packaging.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py
index 9a3778e..07be547 100644
--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -120,9 +120,9 @@ class GPGKeyFixture(fixtures.Fixture):
else:
if gnupg_version is None:
gnupg_version = (0, 0, 0)
- config_file = tempdir.path + '/key-config'
- f = open(config_file, 'wt')
- try:
+
+ config_file = os.path.join(tempdir.path, 'key-config')
+ with open(config_file, 'wt') as f:
if gnupg_version[0] == 2 and gnupg_version[1] >= 1:
f.write("""
%no-protection
@@ -138,8 +138,7 @@ class GPGKeyFixture(fixtures.Fixture):
Preferences: (setpref)
%commit
""")
- finally:
- f.close()
+
# Note that --quick-random (--debug-quick-random in GnuPG 2.x)
# does not have a corresponding preferences file setting and
# must be passed explicitly on the command line instead
@@ -149,6 +148,7 @@ class GPGKeyFixture(fixtures.Fixture):
gnupg_random = '--debug-quick-random'
else:
gnupg_random = ''
+
base._run_cmd(
['gpg', '--gen-key', '--batch', gnupg_random, config_file],
tempdir.path)