commit:     9bf28884e787402e63b94c5450c1a4af98623220
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 11 17:28:09 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Nov 11 17:28:09 2022 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=9bf28884

ebuild/test_eapi.py: fix test_register artifacts

test_register was leaving behind a bunch of files in the EBD_PATH, which
might pollute installation or venv. Create a temporary directory, into
which the ebd is copied and redirected for the duration of the test.

Bug: https://bugs.gentoo.org/880881
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 tests/ebuild/test_eapi.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/ebuild/test_eapi.py b/tests/ebuild/test_eapi.py
index 3d1a98585..48ae0429d 100644
--- a/tests/ebuild/test_eapi.py
+++ b/tests/ebuild/test_eapi.py
@@ -1,6 +1,8 @@
+import shutil
 from unittest import mock
 
 import pytest
+from pkgcore.const import EBD_PATH
 from pkgcore.ebuild import eapi
 from pkgcore.ebuild.eapi import EAPI, eapi6, get_eapi
 
@@ -19,13 +21,15 @@ def test_get_eapi():
 
 class TestEAPI:
 
-    def test_register(self):
+    def test_register(self, tmp_path):
         # re-register known EAPI
         with pytest.raises(ValueError):
             EAPI.register(magic="0")
 
+        mock_ebd_temp = str(shutil.copytree(EBD_PATH, tmp_path / 'ebd'))
         with mock.patch('pkgcore.ebuild.eapi.bash_version') as bash_version, \
-                mock.patch.dict(eapi.EAPI.known_eapis):
+                mock.patch.dict(eapi.EAPI.known_eapis), \
+                mock.patch('pkgcore.ebuild.eapi.const.EBD_PATH', 
mock_ebd_temp):
             # inadequate bash version
             bash_version.return_value = '3.1'
             with pytest.raises(SystemExit) as excinfo:

Reply via email to