Commit 7930b73 1 parent 258d252 commit 7930b73 Copy full SHA for 7930b73
File tree 2 files changed +24
-2
lines changed
2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,13 @@ def _parse_requirement_details(
120
120
return (url , specifier , marker )
121
121
122
122
marker = _parse_requirement_marker (
123
- tokenizer , span_start = specifier_start , after = "version specifier"
123
+ tokenizer ,
124
+ span_start = specifier_start ,
125
+ after = (
126
+ "version specifier"
127
+ if specifier
128
+ else "name and no valid version specifier"
129
+ ),
124
130
)
125
131
126
132
return (url , specifier , marker )
Original file line number Diff line number Diff line change @@ -489,11 +489,27 @@ def test_error_on_missing_op_after_name(self) -> None:
489
489
# THEN
490
490
assert ctx .exconly () == (
491
491
"packaging.requirements.InvalidRequirement: "
492
- "Expected end or semicolon (after version specifier)\n "
492
+ "Expected end or semicolon (after name and no valid version specifier)\n "
493
493
" name 1.0\n "
494
494
" ^"
495
495
)
496
496
497
+ def test_error_on_random_char_after_specifier (self ) -> None :
498
+ # GIVEN
499
+ to_parse = "name >= 1.0 #"
500
+
501
+ # WHEN
502
+ with pytest .raises (InvalidRequirement ) as ctx :
503
+ Requirement (to_parse )
504
+
505
+ # THEN
506
+ assert ctx .exconly () == (
507
+ "packaging.requirements.InvalidRequirement: "
508
+ "Expected end or semicolon (after version specifier)\n "
509
+ " name >= 1.0 #\n "
510
+ " ~~~~~~~^"
511
+ )
512
+
497
513
498
514
class TestRequirementBehaviour :
499
515
def test_types_with_nothing (self ) -> None :
You can’t perform that action at this time.
0 commit comments