From d2f36abd02088cdf1ceb26de2de9c2b33f50c09e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 17 May 2023 12:09:40 +0200 Subject: tests: pypi: Rewrite tests using a local HTTP server. * guix/import/pypi.scm (%pypi-base-url): New variable. (pypi-fetch): Use it. * tests/pypi.scm (foo-json): Compute URLs relative to '%local-url'. (test-json-1, test-json-2, test-source-hash): Remove. (file-dump): New procedure. (with-pypi): New macro. ("pypi->guix-package, no wheel") ("pypi->guix-package, wheels") ("pypi->guix-package, no usable requirement file.") ("pypi->guix-package, package name contains \"-\" followed by digits"): Rewrite using 'with-pypi'. --- guix/import/pypi.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'guix/import') diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm index f780bf1f15..8c06b19cff 100644 --- a/guix/import/pypi.scm +++ b/guix/import/pypi.scm @@ -55,7 +55,8 @@ (define-module (guix import pypi) #:use-module (guix packages) #:use-module (guix upstream) #:use-module ((guix licenses) #:prefix license:) - #:export (parse-requires.txt + #:export (%pypi-base-url + parse-requires.txt parse-wheel-metadata specification->requirement-name guix-package->pypi-name @@ -67,6 +68,10 @@ (define-module (guix import pypi) ;; The PyPI API (notice the rhyme) is "documented" at: ;; . +(define %pypi-base-url + ;; Base URL of the PyPI API. + (make-parameter "https://pypi.org/pypi/")) + (define non-empty-string-or-false (match-lambda ("" #f) @@ -123,7 +128,7 @@ (define-json-mapping make-distribution distribution? (define (pypi-fetch name) "Return a record for package NAME, or #f on failure." - (and=> (json-fetch (string-append "https://pypi.org/pypi/" name "/json")) + (and=> (json-fetch (string-append (%pypi-base-url) name "/json")) json->pypi-project)) ;; For packages found on PyPI that lack a source distribution. -- cgit v1.2.3