aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2019-03-28 00:26:01 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2019-07-02 10:07:59 +0900
commit803fb336d62ea65990e263ce58d8552e04c9c038 (patch)
tree302306159a166490b7837135ba766960d5be5490 /tests
parentc4797121beea74ae93e3ce17677b9e72b8df920d (diff)
downloadguix-803fb336d62ea65990e263ce58d8552e04c9c038.tar
guix-803fb336d62ea65990e263ce58d8552e04c9c038.tar.gz
import: pypi: Improve parsing of requirement specifications.
The previous solution was fragile and could leave unwanted characters in a requirement name, such as '[' or ']'. Partially fixes <https://bugs.gnu.org/33047>. * guix/import/pypi.scm (use-modules): Export SPECIFICATION->REQUIREMENT-NAME (%requirement-name-regexp): New variable. (clean-requirement): Rename to... (specification->requirement-name): this, which now uses %requirement-name-regexp to select the requirement name from the requirement specification. (parse-requires.txt): Adapt.
Diffstat (limited to 'tests')
-rw-r--r--tests/pypi.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/pypi.scm b/tests/pypi.scm
index 03455ba6be..c40be6c21d 100644
--- a/tests/pypi.scm
+++ b/tests/pypi.scm
@@ -55,6 +55,14 @@
(define test-source-hash
"")
+(define test-specifications
+ '("Fizzy [foo, bar]"
+ "PickyThing<1.6,>1.9,!=1.9.6,<2.0a0,==2.4c1"
+ "SomethingWithMarker[foo]>1.0;python_version<\"2.7\""
+ "requests [security,tests] >= 2.8.1, == 2.8.* ; python_version < \"2.7\""
+ "pip @ https://github.com/pypa/pip/archive/1.3.1.zip#\
+sha1=da9234ee9982d4bbb3c72346a6de940a148ea686"))
+
(define test-requires.txt "\
# A comment
# A comment after a space
@@ -109,6 +117,10 @@ pytest (>=2.5.0)
(uri (list "https://bitheap.org/cram/cram-0.7.tar.gz"
(pypi-uri "cram" "0.7"))))))))
+(test-equal "specification->requirement-name"
+ '("Fizzy" "PickyThing" "SomethingWithMarker" "requests" "pip")
+ (map specification->requirement-name test-specifications))
+
(test-equal "parse-requires.txt, with sections"
'("foo" "bar")
(mock ((ice-9 ports) call-with-input-file