git: d7176a1b200c - main - security/py-securesystemslib: switch to USES=pytest, fix tests

From: Dmitry Marakasov <amdmi3_at_FreeBSD.org>
Date: Wed, 27 Apr 2022 11:42:22 UTC
The branch main has been updated by amdmi3:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d7176a1b200c18e8db3c4728de0c1cb5bb170b99

commit d7176a1b200c18e8db3c4728de0c1cb5bb170b99
Author:     Dmitry Marakasov <amdmi3@FreeBSD.org>
AuthorDate: 2022-04-26 14:40:31 +0000
Commit:     Dmitry Marakasov <amdmi3@FreeBSD.org>
CommitDate: 2022-04-27 11:42:12 +0000

    security/py-securesystemslib: switch to USES=pytest, fix tests
    
    Reported by:    reprise
    Approved by:    portmgr blanket
---
 security/py-securesystemslib/Makefile              |  8 ++---
 .../files/patch-tests_test__process.py             | 40 ++++++++++++++++++++++
 2 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/security/py-securesystemslib/Makefile b/security/py-securesystemslib/Makefile
index 643d8ee8ef73..cbfc3e75a93a 100644
--- a/security/py-securesystemslib/Makefile
+++ b/security/py-securesystemslib/Makefile
@@ -13,14 +13,12 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}colorama>=0.3.9:devel/py-colorama@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}cryptography>=3.3.2:security/py-cryptography@${PY_FLAVOR} \
 		${PYTHON_PKGNAMEPREFIX}pynacl>1.2.0:security/py-pynacl@${PY_FLAVOR}
-TEST_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pytest>0:devel/py-pytest@${PY_FLAVOR}
+TEST_DEPENDS=	${LOCALBASE}/bin/gpg:security/gnupg
 
-USES=		python:3.7+
+USES=		python:3.7+ pytest
 USE_PYTHON=	autoplist distutils
+PYTEST_ARGS=	tests
 
 NO_ARCH=	yes
 
-do-test:
-	@cd ${WRKSRC} && ${PYTHON_CMD} -m pytest -v -rs tests
-
 .include <bsd.port.mk>
diff --git a/security/py-securesystemslib/files/patch-tests_test__process.py b/security/py-securesystemslib/files/patch-tests_test__process.py
new file mode 100644
index 000000000000..1801210ce421
--- /dev/null
+++ b/security/py-securesystemslib/files/patch-tests_test__process.py
@@ -0,0 +1,40 @@
+https://github.com/secure-systems-lab/securesystemslib/pull/403
+
+--- tests/test_process.py.orig	2022-02-10 09:48:17 UTC
++++ tests/test_process.py
+@@ -39,7 +39,7 @@ class Test_Process(unittest.TestCase):
+ 
+     stdin_file = open(path)
+     cmd = \
+-        "python -c \"import sys; assert(sys.stdin.read() == '{}')\""
++        sys.executable + " -c \"import sys; assert(sys.stdin.read() == '{}')\""
+ 
+     # input is used in favor of stdin
+     securesystemslib.process.run(cmd.format("use input kwarg"),
+@@ -58,7 +58,7 @@ class Test_Process(unittest.TestCase):
+   def test_run_duplicate_streams(self):
+     """Test output as streams and as returned.  """
+     # Command that prints 'foo' to stdout and 'bar' to stderr.
+-    cmd = ("python -c \""
++    cmd = (sys.executable + " -c \""
+         "import sys;"
+         "sys.stdout.write('foo');"
+         "sys.stderr.write('bar');\"")
+@@ -102,7 +102,7 @@ class Test_Process(unittest.TestCase):
+ 
+   def test_run_cmd_arg_return_code(self):
+     """Test command arg as string and list using return code. """
+-    cmd_str = ("python -c \""
++    cmd_str = (sys.executable + " -c \""
+         "import sys;"
+         "sys.exit(100)\"")
+     cmd_list = shlex.split(cmd_str)
+@@ -118,7 +118,7 @@ class Test_Process(unittest.TestCase):
+   def test_run_duplicate_streams_timeout(self):
+     """Test raise TimeoutExpired. """
+     with self.assertRaises(securesystemslib.process.subprocess.TimeoutExpired):
+-      securesystemslib.process.run_duplicate_streams("python --version",
++      securesystemslib.process.run_duplicate_streams(sys.executable + " --version",
+           timeout=-1)
+ 
+