Subject: [bug#58530] [PATCH 3/4]: gnu: Add pytest-socket

From: Sharlatan Hellseher <[email-masked]>
Date: Fri, 14 Oct 2022 22:12:32 +0100

-- 
… наш разум - превосходная объяснительная машина которая способна
найти смысл почти в чем угодно, истолковать любой феномен, но
совершенно не в состоянии принять мысль о непредсказуемости.
From f5e774473b65f1973756d197d09db415bcb0311c Mon Sep 17 00:00:00 2001
From: Sharlatan Hellseher <[email-masked]>
Date: Fri, 14 Oct 2022 21:42:06 +0100
Subject: [PATCH 3/4] gnu: Add pytest-socket

* gnu/packages/python-check.scm (python-pytest-socket): New variable.
---
 gnu/packages/python-check.scm | 49 +++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/gnu/packages/python-check.scm b/gnu/packages/python-check.scm
index 2358e7448d..fd88fc480e 100644
--- a/gnu/packages/python-check.scm
+++ b/gnu/packages/python-check.scm
@@ -395,6 +395,55 @@ (define-public python-vcrpy
 interactions, which will update them to correspond to the new API.")
     (license license:expat)))
 
+(define-public python-pytest-socket
+  (package
+    (name "python-pytest-socket")
+    (version "0.5.1")
+    (source (origin
+              (method url-fetch)
+              (uri (pypi-uri "pytest-socket" version))
+              (sha256
+               (base32
+                "1dkr86nxkxc0ka3rdnpmk335m8gl1zh1sy8i7w4w1jsidbf82jvw"))))
+    (build-system python-build-system)
+    (arguments
+     ;; FIXME: Tests fail a lot, probably requiring Internet access.
+     (list #:tests? #f
+           #:phases #~(modify-phases %standard-phases
+                        (replace 'build
+                          (lambda _
+                            (setenv "SETUPTOOLS_SCM_PRETEND_VERSION"
+                                    #$version)
+                            (setenv "SOURCE_DATE_EPOCH" "315532800")
+                            (invoke "python"
+                                    "-m"
+                                    "build"
+                                    "--wheel"
+                                    "--no-isolation"
+                                    ".")))
+                        (add-before 'check 'disable-unsupported-test
+                          (lambda _
+                            (substitute* "tests/test_async.py"
+                              (("def test_asynctest")
+                               "def __off_test_asynctest"))))
+                        (replace 'check
+                          (lambda* (#:key tests? #:allow-other-keys)
+                            (when tests?
+                              (invoke "python" "-m" "pytest" "-vvv")))))))
+    (native-inputs (list python-httpx
+                         python-poetry-core
+                         python-pypa-build
+                         python-pytest
+                         python-pytest-httpbin
+                         python-pytest-randomly
+                         python-starlette))
+    (home-page "https://pypi.org/project/pytest-socket/")
+    (synopsis "Pytest plugin to disable socket calls during tests")
+    (description
+     "This package provides Pytest extension which disables all network calls flowing
+through Python's socket interface")
+    (license license:expat)))
+
 (define-public python-pytest-ordering
   (package
     (name "python-pytest-ordering")
-- 
2.37.3