This is an automated email from the git hooks/post-receive script.
praiskup pushed a commit to branch master
in repository copr/copr.
commit 2f1ddf1a242f2ffa46284ebd555c965d37802c99
Author: Jakub Kadlcik <frostyx(a)email.cz>
AuthorDate: Tue Feb 18 13:27:39 2020 +0100
rpmbuild: fix tests for EPEL6 an 7
The number of `rmtree` calls required for removing a nested directory
differs between Fedora/python3 and EPEL/python2. It is either bug
in `mock` module (which is used only for python2) or the `rmtree`
implementation changed from having recursive calls to having a loop.
I am modifying the test to work on both Fedora and EPEL chroots and
also adding a special case for EPEL to check that those multiple
`rmtree` calls affect only the one desired directory.
Relates: #1262
---
rpmbuild/tests/test_main.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/rpmbuild/tests/test_main.py b/rpmbuild/tests/test_main.py
index b1b1594..67080aa 100644
--- a/rpmbuild/tests/test_main.py
+++ b/rpmbuild/tests/test_main.py
@@ -8,9 +8,11 @@ from copr_rpmbuild.helpers import SourceType
try:
from unittest import mock
+ EPEL = False
except ImportError:
# Python 2 version depends on mock
import mock
+ EPEL = True
class TestTmpCleanup(unittest.TestCase):
@@ -28,15 +30,24 @@ class TestTmpCleanup(unittest.TestCase):
# Test that we cleanup after successful build
produce_srpm(self.task, self.config, self.resultdir)
- args, _ = mock_rmtree.call_args
- assert mock_rmtree.call_count == 1
- assert args[0].startswith("/tmp/copr-rpmbuild-")
+ assert mock_rmtree.call_count == (1 if not EPEL else 2)
+ for call in mock_rmtree.call_args_list:
+ args, _ = call
+ assert args[0].startswith("/tmp/copr-rpmbuild-")
+
+ # Just to check, that on EPEL it recursively removes one directory,
+ # not two different directories. Do not run this check on Fedora/Python3
+ # because there the directory is removed on one rmtree call.
+ if EPEL:
+ assert mock_rmtree.call_args_list[1][0][0] == \
+ os.path.join(mock_rmtree.call_args_list[0][0][0],
"obtain-sources")
# Test that we cleanup after unsuccessful build
mock_produce_srpm.side_effect = RuntimeError("Jeeez, something
failed")
with pytest.raises(RuntimeError):
produce_srpm(self.task, self.config, self.resultdir)
- args, _ = mock_rmtree.call_args
- assert mock_rmtree.call_count == 2
- assert args[0].startswith("/tmp/copr-rpmbuild-")
+ assert mock_rmtree.call_count == (2 if not EPEL else 4)
+ for call in mock_rmtree.call_args_list:
+ args, _ = call
+ assert args[0].startswith("/tmp/copr-rpmbuild-")
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.