librepo/0001-Fix-rmtree-failure-in-tearDown.patch

86 lines
3.4 KiB
Diff

From 7ee6f0be21c9c841e14e1c1008cf7c3634da0831 Mon Sep 17 00:00:00 2001
From: Tomas Orsava <torsava@redhat.com>
Date: Fri, 18 Aug 2017 14:37:16 +0200
Subject: [PATCH] Fix rmtree failure in tearDown
We need to remove the S.gpg-agent sockets, because when one of the
sockets gets closed by shutil.rmtree, gpg will try to close the 3
remaining sockets and may do it before shutil.rmtree deletes them.
This results in rmtree trying to delete a non existing file and can
exiting with an error `No such file or directory`.
---
tests/python/tests/test_yum_repo_downloading.py | 17 ++++++++++++++++-
tests/python/tests/test_yum_repo_locating.py | 17 ++++++++++++++++-
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/tests/python/tests/test_yum_repo_downloading.py b/tests/python/tests/test_yum_repo_downloading.py
index ad597dc..0049946 100644
--- a/tests/python/tests/test_yum_repo_downloading.py
+++ b/tests/python/tests/test_yum_repo_downloading.py
@@ -2,7 +2,7 @@ import sys
import time
import gpgme
import shutil
-import os.path
+import os
import tempfile
import unittest
@@ -32,6 +32,21 @@ class TestCaseYumRepoDownloading(TestCaseWithFlask):
os.environ.pop('GNUPGHOME')
else:
os.environ['GNUPGHOME'] = self._gnupghome
+
+ # We need to remove the S.gpg-agent sockets, because when one of the
+ # sockets gets closed by shutil.rmtree, gpg will try to close the 3
+ # remaining sockets and may do it before shutil.rmtree deletes them.
+ # This results in rmtree trying to delete a non existing file and can
+ # exiting with an error `No such file or directory`.
+ try:
+ gpg_agent_files = ["S.gpg-agent", "S.gpg-agent.browser",
+ "S.gpg-agent.extra", "S.gpg-agent.ssh"]
+ for file in gpg_agent_files:
+ os.remove(os.path.join(self.tmpdir, "keyring", file))
+ except OSError:
+ # GPG deleted the remaining file(s) faster then we did
+ pass
+
shutil.rmtree(self.tmpdir)
def test_download_repo_01(self):
diff --git a/tests/python/tests/test_yum_repo_locating.py b/tests/python/tests/test_yum_repo_locating.py
index 8f4bea5..02d6aea 100644
--- a/tests/python/tests/test_yum_repo_locating.py
+++ b/tests/python/tests/test_yum_repo_locating.py
@@ -1,4 +1,4 @@
-import os.path
+import os
import tempfile
import shutil
import unittest
@@ -34,6 +34,21 @@ class TestCaseYumRepoLocating(TestCase):
os.environ.pop('GNUPGHOME')
else:
os.environ['GNUPGHOME'] = self._gnupghome
+
+ # We need to remove the S.gpg-agent sockets, because when one of the
+ # sockets gets closed by shutil.rmtree, gpg will try to close the 3
+ # remaining sockets and may do it before shutil.rmtree deletes them.
+ # This results in rmtree trying to delete a non existing file and can
+ # exiting with an error `No such file or directory`.
+ try:
+ gpg_agent_files = ["S.gpg-agent", "S.gpg-agent.browser",
+ "S.gpg-agent.extra", "S.gpg-agent.ssh"]
+ for file in gpg_agent_files:
+ os.remove(os.path.join(self.tmpdir, "keyring", file))
+ except OSError:
+ # GPG deleted the remaining file(s) faster then we did
+ pass
+
shutil.rmtree(self.tmpdir)
def test_read_mirrorlist(self):
--
2.13.5